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

eslint-plugin-sonarjs

Package Overview
Dependencies
Maintainers
3
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-sonarjs - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0-internal

31

lib/rules/cognitive-complexity.js

@@ -31,3 +31,3 @@ "use strict";

// internal parameter
enum: ["sonar-runtime"],
enum: ["sonar-runtime", "metric"],
},

@@ -38,2 +38,5 @@ ],

var threshold = context.options[0] !== undefined ? context.options[0] : DEFAULT_THRESHOLD;
var isFileComplexity = context.options.includes("metric");
/** Complexity of the file */
var fileComplexity = 0;
/** Complexity of the current function if it is *not* considered nested to the first level function */

@@ -74,2 +77,12 @@ var complexityIfNotNested = [];

},
Program: function () {
fileComplexity = 0;
},
"Program:exit": function (node) {
if (isFileComplexity) {
// as issues are the only communication channel of a rule
// we pass data as serialized json as an issue message
context.report({ node: node, message: fileComplexity.toString() });
}
},
IfStatement: function (node) {

@@ -234,3 +247,7 @@ visitIfStatement(node);

var complexityPoint = { complexity: added, location: location };
if (enclosingFunctions.length === 1) {
if (enclosingFunctions.length === 0) {
// top level scope
fileComplexity += added;
}
else if (enclosingFunctions.length === 1) {
// top level function

@@ -248,3 +265,7 @@ topLevelHasStructuralComplexity = true;

var complexityPoint = { complexity: 1, location: location };
if (enclosingFunctions.length === 1) {
if (enclosingFunctions.length === 0) {
// top level scope
fileComplexity += 1;
}
else if (enclosingFunctions.length === 1) {
// top level function

@@ -262,2 +283,6 @@ topLevelOwnComplexity.push(complexityPoint);

var complexityAmount = complexity.reduce(function (acc, cur) { return acc + cur.complexity; }, 0);
fileComplexity += complexityAmount;
if (isFileComplexity) {
return;
}
if (complexityAmount > threshold) {

@@ -264,0 +289,0 @@ var secondaryLocations = complexity.map(function (complexityPoint) {

2

package.json
{
"name": "eslint-plugin-sonarjs",
"version": "0.4.0",
"version": "0.5.0-internal",
"description": "SonarJS rules for ESLint",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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