parroit/crafter

View on GitHub

Showing 26 of 26 total issues

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

module.exports = function(targetPath, exports) {
    var modules = [];
    var builder;
    var exportsIds = {};
    exports = exports || [];
Severity: Minor
Found in lib/ast-body-concat.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 exports has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(targetPath, exports) {
    var modules = [];
    var builder;
    var exportsIds = {};
    exports = exports || [];
Severity: Major
Found in lib/ast-body-concat.js - About 2 hrs to fix

    Function astRequireFinder has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function astRequireFinder (options){
        return function (node) {
            //jshint validthis:true
            var file = this;
    
    Severity: Major
    Found in lib/ast-require-finder.js - About 2 hrs to fix

      Function end has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          }, function end() {
              var stream = this;
      
              if (cachedTemplate) {
                  applyTemplate(cachedTemplate);
      Severity: Minor
      Found in lib/ast-body-concat.js - About 1 hr to fix

        Function repipeRequirement has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function repipeRequirement(adapter) {
            var builder;
            return through2.obj(function loadRequired(file, enc, next) {
                if (!file.requires) {
                    this.push(file);
        Severity: Minor
        Found in lib/repipe-requirement.js - About 1 hr to fix

          Function createBundle has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function createBundle(output, sourceFileGlob) {
              var outputPath = path.resolve(process.cwd(), output);
              winston.info('Reading source files ', sourceFileGlob);
              winston.info('Writing result to ', outputPath);
          
          Severity: Minor
          Found in bin/crafter-bundle.js - About 1 hr to fix

            Function loadRequired has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                return through2.obj(function loadRequired(file, enc, next) {
                    if (!file.requires) {
                        this.push(file);
                        return next();
                    }
            Severity: Minor
            Found in lib/repipe-requirement.js - About 1 hr to fix

              Function astVisitor has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function astVisitor(visitors) {
                  if (typeof visitors === 'function') {
                      visitors = [visitors];
                  }
                  return through2.obj(function visit(file, enc, next) {
              Severity: Minor
              Found in lib/ast-visitor.js - About 1 hr to fix

                Function repipeRequirement has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                function repipeRequirement(adapter) {
                    var builder;
                    return through2.obj(function loadRequired(file, enc, next) {
                        if (!file.requires) {
                            this.push(file);
                Severity: Minor
                Found in lib/repipe-requirement.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 astParser has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                function astParser(options) {
                    options = options || {loc:true};
                    options.loc = 'loc' in options ? options.loc :  true;
                    options.parsers = options.parsers || {
                        js: parseJs,
                Severity: Minor
                Found in lib/ast-parser.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 applyTemplate has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        function applyTemplate(template) {
                            try {
                                var file = new File({
                                    path: targetPath
                                });
                Severity: Minor
                Found in lib/ast-body-concat.js - About 1 hr to fix

                  Function runProgram has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function runProgram(er, data) {
                      if (er) {
                          winston.error('There was an error reading the file ' + packagePath + '\n\n' + er.stack);
                          return;
                      }
                  Severity: Minor
                  Found in bin/crafter.js - About 1 hr to fix

                    Function astParser has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function astParser(options) {
                        options = options || {loc:true};
                        options.loc = 'loc' in options ? options.loc :  true;
                        options.parsers = options.parsers || {
                            js: parseJs,
                    Severity: Minor
                    Found in lib/ast-parser.js - About 1 hr to fix

                      Function astVisitor has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function astVisitor(visitors) {
                          if (typeof visitors === 'function') {
                              visitors = [visitors];
                          }
                          return through2.obj(function visit(file, enc, next) {
                      Severity: Minor
                      Found in lib/ast-visitor.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 visit has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          return through2.obj(function visit(file, enc, next) {
                              var _this = this;
                              winston.verbose('astVisitor -> ', file && file.path);
                              if (file.isNull()) {
                                  _this.push(file); // pass along
                      Severity: Minor
                      Found in lib/ast-visitor.js - About 1 hr to fix

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

                                .pipe(through2.obj(function visit(file, enc, next) {
                                    if (file.isNull()) {
                                        this.push(file); // pass along
                                        return next();
                                    }
                        Severity: Minor
                        Found in bin/crafter-bundle.js - About 1 hr to fix

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

                          function modulesBuilder() {
                              var builder = {
                                  rootModules:{},
                                  modules:{},
                                  resolved:{},
                          Severity: Minor
                          Found in lib/modules-builder.js - About 1 hr to fix

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

                            function assignModuleId() {
                                var id = 0;
                                var allFiles = [];
                                return through(function write(file) {
                                    
                            Severity: Minor
                            Found in lib/assign-module-id.js - About 1 hr to fix

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

                              gulp.task('quality', function () {
                                return gulp.src('./test/*.js')
                                  .pipe(mocha({
                                    ui: 'bdd',
                                    reporter: 'spec',
                              Severity: Major
                              Found in gulpfile.js and 1 other location - About 1 hr to fix
                              gulpfile.js on lines 34..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 56.

                              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

                              gulp.task('only', function () {
                                return gulp.src('./test/*.js')
                                  .pipe(mocha({
                                    ui: 'bdd',
                                    reporter: 'spec',
                              Severity: Major
                              Found in gulpfile.js and 1 other location - About 1 hr to fix
                              gulpfile.js on lines 44..51

                              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 56.

                              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

                              Severity
                              Category
                              Status
                              Source
                              Language