New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@syntest/search

Package Overview
Dependencies
Maintainers
4
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@syntest/search - npm Package Compare versions

Comparing version 0.4.0-beta.45 to 0.4.0-beta.46

12

dist/lib/objective/BranchObjectiveFunction.d.ts

@@ -18,2 +18,14 @@ import { Logger } from "@syntest/logging";

constructor(approachLevel: ApproachLevel, branchDistance: BranchDistance, subject: SearchSubject<T>, id: string);
/**
* Calculating the distance for a single encoding
*
* This returns a number structured as follows: XX.YYZZZZ
* Where:
* - XX is the approach level
* - YY is the fraction of uncovered statements within the block
* - ZZZZ is the branch distance from the objective
*
* @param encoding
* @returns
*/
calculateDistance(encoding: T): number;

@@ -20,0 +32,0 @@ protected _calculateControlFlowDistance(executionResult: ExecutionResult): number;

37

dist/lib/objective/BranchObjectiveFunction.js

@@ -37,2 +37,14 @@ "use strict";

}
/**
* Calculating the distance for a single encoding
*
* This returns a number structured as follows: XX.YYZZZZ
* Where:
* - XX is the approach level
* - YY is the fraction of uncovered statements within the block
* - ZZZZ is the branch distance from the objective
*
* @param encoding
* @returns
*/
// eslint-disable-next-line sonarjs/cognitive-complexity

@@ -76,18 +88,15 @@ calculateDistance(encoding) {

if (statementFraction !== -1 && statementFraction !== 1) {
// the statement fraction should never be -1
// if the statement fraction is 1 it is fully covered
// TODO or the error happens at the end of a body where we dont record traces anymore
// TODO there can still be a crash inside of the if statement making the branch distance still zero
// TODO this is a hack to give guidance to the algorithm
// it would be better to improve the cfg with implicit branches
// or to atleast choose a number based on what statement has been covered in the cfg node
// 0.25 is based on the fact the branch distance is minimally 0.5 // TODO FALSE!!!!
// so 0.25 is exactly between 0.5 and 0
return approachLevel + 0.48 * statementFraction + 0.01;
// Here we use the fractions of unreached statements to generate a number between 0.01 and 0.99
// It must be larger than 0 otherwise it seems like the node is actually covered
// It must be smaller than 1 otherwise it would be the same as one further node in the approach level
// This represents the YY part in the distance (XX.YYZZZZ)
let distance = (1 - statementFraction) * 0.98 + 0.01;
distance = Math.round(distance * 100) / 100;
return approachLevel + distance;
}
if (outgoingEdges.length < 2) {
// todo end of block problem
// end of block problem
// when a crash happens at the last line of a block the statement fraction becomes 1 since we do not record the last one
if (statementFraction === 1) {
return approachLevel + 0.499999999;
return approachLevel + 0.01;
}

@@ -143,3 +152,5 @@ throw new Error((0, diagnostics_1.shouldNeverHappen)("Statement fraction should not be zero because that means it rashed on the conditional instead of the first statement of a blok, could be that the traces are wrong"));

// add the distances
return approachLevel + branchDistance;
// We divide the branch distance by 100 to "free up" the YY part of the distance metric
// The branch distance represents the ZZZZ part in the distance (XX.YYZZZZ)
return approachLevel + branchDistance / 100;
}

@@ -146,0 +157,0 @@ }

{
"name": "@syntest/search",
"version": "0.4.0-beta.45",
"version": "0.4.0-beta.46",
"description": "The common core of the SynTest Framework",

@@ -64,3 +64,3 @@ "keywords": [

},
"gitHead": "f4ff81ed804a5965088d6486f4682aefda64a799"
"gitHead": "7d6ce4e1d9b7d4a8fb172c91af25d42ad918d2bd"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc