ZenitechSoftware/visa-js

View on GitHub
lib/acm.js

Summary

Maintainability
A
2 hrs
Test Coverage
A
100%

Function createEvaluationFunction has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const createEvaluationFunction = (rule, mapRefsToObjects, objectName, operationName) => function (args) {
  const result = args && (args.ref || args.refs || args.object || args.objects)
    ? evaluateRulesForObjects(objectName, operationName, rule, this.subject, mapRefsToObjects, args)
    : evaluateRule(objectName, operationName, rule, this.subject, undefined, args && args.context);
  if (this.isAsk) {
Severity: Minor
Found in lib/acm.js - About 1 hr to fix

    Function createPolicyFunction has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Wontfix

    const createPolicyFunction = (Can) => policy => {
      for (let objectName of Object.keys(policy.objects)) {
        for (let operationName of Object.keys(policy.objects[objectName].operations)) {
          if (!Can.prototype[operationName]) {
            class Operation {
    Severity: Minor
    Found in lib/acm.js - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function createEvaluationFunction has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const createEvaluationFunction = (rule, mapRefsToObjects, objectName, operationName) => function (args) {
      const result = args && (args.ref || args.refs || args.object || args.objects)
        ? evaluateRulesForObjects(objectName, operationName, rule, this.subject, mapRefsToObjects, args)
        : evaluateRule(objectName, operationName, rule, this.subject, undefined, args && args.context);
      if (this.isAsk) {
    Severity: Minor
    Found in lib/acm.js - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function evaluateRuleForObjects has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const evaluateRuleForObjects = (objectName, operationName, rule, subject, objects, context) =>
      new Promise((resolve, reject) => async.eachLimit(
        objects,
        5,
        (object, cb) => evaluateRule(objectName, operationName, rule, subject, object, context).then(cb).catch(cb),
    Severity: Minor
    Found in lib/acm.js - About 25 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Definition for rule 'switch-colon-spacing' was not found
    Open

    const async = require('async');
    Severity: Minor
    Found in lib/acm.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    Definition for rule 'array-bracket-newline' was not found
    Open

    const async = require('async');
    Severity: Minor
    Found in lib/acm.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    Definition for rule 'lines-between-class-members' was not found
    Open

    const async = require('async');
    Severity: Minor
    Found in lib/acm.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    Definition for rule 'multiline-comment-style' was not found
    Open

    const async = require('async');
    Severity: Minor
    Found in lib/acm.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    Definition for rule 'no-buffer-constructor' was not found
    Open

    const async = require('async');
    Severity: Minor
    Found in lib/acm.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    Definition for rule 'getter-return' was not found
    Open

    const async = require('async');
    Severity: Minor
    Found in lib/acm.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    Definition for rule 'padding-line-between-statements' was not found
    Open

    const async = require('async');
    Severity: Minor
    Found in lib/acm.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    Definition for rule 'semi-style' was not found
    Open

    const async = require('async');
    Severity: Minor
    Found in lib/acm.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    Definition for rule 'for-direction' was not found
    Open

    const async = require('async');
    Severity: Minor
    Found in lib/acm.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    There are no issues that match your filters.

    Category
    Status