qiu8310/coding

View on GitHub

Showing 13 of 15 total issues

Function renameRequire has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

function renameRequire(ast, filePath, opts) {
  var aliasMap = {},
    addAlias = function(alias) { if (alias) { _.assign(aliasMap, alias); } },
    delAlias = function(alias) { if (alias) { aliasMap = _.omit(aliasMap, _.keys(alias)); } };

Severity: Minor
Found in src/lib/refactor.js - About 4 hrs 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 removeExport has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

function removeExport(ast, filePath, opts) {
  var bodyNodes = ast.body, node, obj, prop, i, statCount = 0, exportCount = 0, exportMember, exportGlobal = false;

  var exp = rename(filePath, opts);

Severity: Minor
Found in src/lib/refactor.js - About 3 hrs 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 findAllRequiredFile has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

function findAllRequiredFile(filePath) {
  var ast = helper.getFileAST(filePath),
    result = [];

  //require('fs').writeFile(filePath.replace(/\.js$/, '.json'), JSON.stringify(ast, null, 2));
Severity: Minor
Found in src/lib/traverse.js - About 3 hrs 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 removeExport has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function removeExport(ast, filePath, opts) {
  var bodyNodes = ast.body, node, obj, prop, i, statCount = 0, exportCount = 0, exportMember, exportGlobal = false;

  var exp = rename(filePath, opts);

Severity: Major
Found in src/lib/refactor.js - About 2 hrs to fix

    Function removeRequire has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    function removeRequire(ast, filePath, opts) {
      var removePaths = [];
      estraverse.traverse(ast, {
        enter: function(node, parent) {
          if (node.type === 'VariableDeclaration') {
    Severity: Minor
    Found in src/lib/refactor.js - About 2 hrs 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 renameRequire has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function renameRequire(ast, filePath, opts) {
      var aliasMap = {},
        addAlias = function(alias) { if (alias) { _.assign(aliasMap, alias); } },
        delAlias = function(alias) { if (alias) { aliasMap = _.omit(aliasMap, _.keys(alias)); } };
    
    
    Severity: Minor
    Found in src/lib/refactor.js - About 1 hr to fix

      Function removeRequire has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function removeRequire(ast, filePath, opts) {
        var removePaths = [];
        estraverse.traverse(ast, {
          enter: function(node, parent) {
            if (node.type === 'VariableDeclaration') {
      Severity: Minor
      Found in src/lib/refactor.js - About 1 hr to fix

        Function findAllRequiredFile has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function findAllRequiredFile(filePath) {
          var ast = helper.getFileAST(filePath),
            result = [];
        
          //require('fs').writeFile(filePath.replace(/\.js$/, '.json'), JSON.stringify(ast, null, 2));
        Severity: Minor
        Found in src/lib/traverse.js - About 1 hr to fix

          Function exports has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports = function(filePath, opts) {
            opts = _.assign({
              global: 'G',
              rename: null,
              transform: null,  // should be function
          Severity: Minor
          Found in src/coding.js - About 1 hr to fix

            Function enter has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                enter: function(node, parent) {
                  addAlias(node._alias);
            
                  var i, id, param, t;
                  // 函数中的参数如果包含有 alias 的话,则之后出现的 alias 全部忽略
            Severity: Minor
            Found in src/lib/refactor.js - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                        if (!exportMember) {
                          exportGlobal = true;
                        }
              Severity: Major
              Found in src/lib/refactor.js - About 45 mins to fix

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

                module.exports = function(filePath, opts) {
                  opts = _.assign({
                    global: 'G',
                    rename: null,
                    transform: null,  // should be function
                Severity: Minor
                Found in src/coding.js - About 35 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 rename has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function rename(filePath, opts) {
                  var res;
                  if (opts.rename && typeof opts.rename === 'function') {
                    res = opts.rename(filePath);
                    if (typeof res === 'string') {
                Severity: Minor
                Found in src/lib/refactor.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

                Severity
                Category
                Status
                Source
                Language