phadej/jsstana

View on GitHub

Showing 33 of 33 total issues

Function cli has 92 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function cli(argv) {
  program.parse(argv);
  if (program.stripShebang === undefined) { program.stripShebang = true; }
  if (program.lineNumber === undefined) { program.lineNumber = true; }
  if (program.fileName === undefined) { program.fileName = true; }
Severity: Major
Found in bin/jsgrep.js - About 3 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      return misc.nodeMatcher("MemberExpression", function (node) {
        if (computed !== undefined && node.computed !== computed) { return undefined; }
    
        var objectM = objectMatcher(node.object);
        var propertyM = propertyMatcher(node.property);
    Severity: Major
    Found in lib/matchers/member.js and 1 other location - About 2 hrs to fix
    lib/matchers/operator.js on lines 145..152

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 86.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      return misc.nodeMatcher("UpdateExpression", function (node) {
        if (prefix !== undefined && node.prefix !== prefix) { return undefined; }
    
        var opM = opMatcher(node.operator);
        var valueM = valueMatcher(node.argument);
    Severity: Major
    Found in lib/matchers/operator.js and 1 other location - About 2 hrs to fix
    lib/matchers/member.js on lines 26..33

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 86.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function callMatcher has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function callMatcher(callnew, callee) {
      /* jshint validthis:true */
      callee = callee || "?";
    
      var calleeMatcher = this.matcher(callee);
    Severity: Major
    Found in lib/matchers/call.js - About 2 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      module.exports = jsstana.eslintRule("(call (property (call (property ? sortBy)) uniq) ??params)", function(context, node, m) {
        if (m.params.length === 0 || !jsstana.match("(true)", m.params[0])) {
          context.report(node, "Pass `true` as second argument to _.uniq, when uniq-ing result of _.sortBy");
        }
      });
      Severity: Major
      Found in eslint-rules/underscore-sort-uniq-2.js and 1 other location - About 2 hrs to fix
      eslint-rules/underscore-sort-uniq-1.js on lines 5..9

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 82.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      module.exports = jsstana.eslintRule("(call _.uniq (call _.sortBy ??) ??params)", function(context, node, m) {
        if (m.params.length === 0 || !jsstana.match("(true)", m.params[0])) {
          context.report(node, "Pass `true` as second argument to _.uniq, when uniq-ing result of _.sortBy");
        }
      });
      Severity: Major
      Found in eslint-rules/underscore-sort-uniq-1.js and 1 other location - About 2 hrs to fix
      eslint-rules/underscore-sort-uniq-2.js on lines 5..9

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 82.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function exports has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      module.exports = jsstana.eslintRule("(var ?name (call require ?param))", function(context, node, m) {
        var n = jsstana.match("(string ?paramname)", m.param);
        if (!n) {
          context.report(m.param, "require argument isn't string");
        }
      Severity: Minor
      Found in eslint-rules/npm-require-name.js - About 1 hr 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 enter has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                enter: function (node /* , parent */) {
                  var match = pattern(node);
                  if (match) {
                    if (!lines) {
                      lines = contents.toString().split(/\n/);
      Severity: Minor
      Found in bin/jsgrep.js - About 1 hr to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          return misc.nodeMatcher(exprType, function (node) {
            var opM = opMatcher(node.operator);
            var lhsM = lhsMatcher(node.left);
            var rhsM = rhsMatcher(node.right);
        
        
        Severity: Major
        Found in lib/matchers/operator.js and 1 other location - About 1 hr to fix
        lib/matchers/ternary.js on lines 23..29

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 65.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          return misc.nodeMatcher("ConditionalExpression", function (node) {
            var testM = testMatcher(node.test);
            var consequentM = consequentMatcher(node.consequent);
            var alternateM = alternateMatcher(node.alternate);
        
        
        Severity: Major
        Found in lib/matchers/ternary.js and 1 other location - About 1 hr to fix
        lib/matchers/operator.js on lines 85..91

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 65.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          return misc.nodeMatcher("VariableDeclarator", function (node) {
            var idM = idMatcher(node.id);
            var initM = initMatcher(node.init);
            return that.combineMatches(idM, initM);
          });
        Severity: Major
        Found in lib/matchers/ident.js and 1 other location - About 1 hr to fix
        lib/matchers/operator.js on lines 117..122

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 60.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          return misc.nodeMatcher("UnaryExpression", function (node) {
            var opM = opMatcher(node.operator);
            var valueM = valueMatcher(node.argument);
        
            return that.combineMatches(opM, valueM);
        Severity: Major
        Found in lib/matchers/operator.js and 1 other location - About 1 hr to fix
        lib/matchers/ident.js on lines 64..68

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 60.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function matcherString has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function matcherString(sexpr) {
          /* jshint validthis:true */
          var that = this;
        
          if (sexpr.indexOf(".") !== -1) {
        Severity: Minor
        Found in lib/jsstana.js - About 1 hr to fix

          Function colorizeLine has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function colorizeLine(line, steps) {
            steps = _.sortBy(steps, "pos");
          
            var prevPos = 0;
            var currVal = 0;
          Severity: Minor
          Found in bin/jsgrep.js - About 1 hr to fix

            Function compileCallMatcher has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function compileCallMatcher(args) {
              /* jshint validthis:true */
            
              var groups = args.map(function (arg) {
                if (typeof arg === "string" && arg.substr(0, 2) === "??") {
            Severity: Minor
            Found in lib/matchers/call.js - About 1 hr to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                } else {
                  var ident = misc.LITERALS[type];
                  return misc.nodeMatcher("Identifier", function (node) {
                    return node.name === ident ? {} : undefined;
                  });
              Severity: Minor
              Found in lib/matchers/literal.js and 1 other location - About 55 mins to fix
              lib/matchers/literal.js on lines 31..36

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 54.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                if (_.has(misc.CONSTANTS, type)) {
                  var value = misc.CONSTANTS[type];
                  return misc.nodeMatcher("Literal", function (node) {
                    return node.value === value ? {} : undefined;
                  });
              Severity: Minor
              Found in lib/matchers/literal.js and 1 other location - About 55 mins to fix
              lib/matchers/literal.js on lines 36..41

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 54.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                } else if (sexpr[0] === "?") {
                  sexpr = sexpr.substr(1);
                  return function (node) {
                    var res = {};
                    res[sexpr] = node;
              Severity: Minor
              Found in lib/jsstana.js and 1 other location - About 45 mins to fix
              lib/matchers/operator.js on lines 10..22

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 50.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                } else if (operator[0] === "?") {
                  operator = operator.substr(1);
                  return function (op) {
                    var res = {};
                    res[operator] = op;
              Severity: Minor
              Found in lib/matchers/operator.js and 1 other location - About 45 mins to fix
              lib/jsstana.js on lines 127..147

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 50.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Function binaryAssignMatcher has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function binaryAssignMatcher(ratorName, validOperators, exprType, operator, lhs, rhs) {
              Severity: Minor
              Found in lib/matchers/operator.js - About 45 mins to fix
                Severity
                Category
                Status
                Source
                Language