meteor/meteor

View on GitHub
tools/isobuild/package-source.js

Summary

Maintainability
F
1 wk
Test Coverage

File package-source.js has 1066 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var _ = require('underscore');
var files = require('../fs/files');
var utils = require('../utils/utils.js');
var watch = require('../fs/watch');
var buildmessage = require('../utils/buildmessage.js');
Severity: Major
Found in tools/isobuild/package-source.js - About 2 days to fix

    Function initFromPackageDir has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

      }, function (dir, options) {
        var self = this;
        buildmessage.assertInCapture();
        var isPortable = true;
        options = options || {};
    Severity: Minor
    Found in tools/isobuild/package-source.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 initFromAppDir has 98 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      initFromAppDir: Profile("initFromAppDir", function (projectContext, ignoreFiles) {
        var self = this;
        var appDir = projectContext.projectDir;
        self.name = null;
        self.sourceRoot = appDir;
    Severity: Major
    Found in tools/isobuild/package-source.js - About 3 hrs to fix

      Function _inferAppFileOptions has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

        _inferAppFileOptions(relPath, {
          arch,
          mainModule,
          testModule,
        }) {
      Severity: Minor
      Found in tools/isobuild/package-source.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 _computeDependencyMetadata has 79 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _computeDependencyMetadata: function (options) {
          var self = this;
          options = options || {};
      
          var dependencies = {};
      Severity: Major
      Found in tools/isobuild/package-source.js - About 3 hrs to fix

        Function loadOrderSort has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        var loadOrderSort = function (sourceProcessorSet, arch) {
          const isTemplate = _.memoize((filename) => {
            const classification = sourceProcessorSet.classifyFilename(filename, arch);
            switch (classification.type) {
            case 'extension':
        Severity: Major
        Found in tools/isobuild/package-source.js - About 2 hrs to fix

          Function _inferAppFileOptions has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            _inferAppFileOptions(relPath, {
              arch,
              mainModule,
              testModule,
            }) {
          Severity: Major
          Found in tools/isobuild/package-source.js - About 2 hrs to fix

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

              initFromOptions: function (name, options) {
                var self = this;
                self.name = name;
            
                if (options.sources && ! _.isEmpty(options.sources) &&
            Severity: Minor
            Found in tools/isobuild/package-source.js - About 1 hr to fix

              Function getFiles has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      getFiles(sourceProcessorSet, watchSet) {
                        sourceProcessorSet.watchSet = watchSet;
              
                        const findOptions = {
                          sourceProcessorSet,
              Severity: Minor
              Found in tools/isobuild/package-source.js - About 1 hr to fix

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

                  processReadme: function () {
                    var self = this;
                    buildmessage.assertInJob();
                    if (! self.metadata.documentation) {
                      return null;
                Severity: Minor
                Found in tools/isobuild/package-source.js - About 1 hr to fix

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

                        var processUse = function (implied, use) {
                          // We can't really have a weak implies (what does that even mean?) but
                          // we check for that elsewhere.
                          if ((use.weak && options.skipWeak) ||
                              (use.unordered && options.skipUnordered)) {
                  Severity: Minor
                  Found in tools/isobuild/package-source.js - About 1 hr to fix

                    Function _findAssets has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      _findAssets({
                        sourceProcessorSet,
                        watchSet,
                        isApp,
                        sourceArch,
                    Severity: Minor
                    Found in tools/isobuild/package-source.js - About 1 hr to fix

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

                              getFiles(sourceProcessorSet, watchSet) {
                                const result = api.files[arch];
                                const relPathToSourceObj = Object.create(null);
                                const sources = result.sources;
                      
                      
                      Severity: Minor
                      Found in tools/isobuild/package-source.js - About 1 hr to fix

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

                          getPackagesToLoadFirst: function (packageMap) {
                            var self = this;
                            var packages = {};
                            var processUse = function (use) {
                              // We don't have to build weak or unordered deps first (eg they can't
                        Severity: Minor
                        Found in tools/isobuild/package-source.js - About 1 hr to fix

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

                          var getExcerptFromReadme = function (text) {
                            // Don't waste time parsing if the document is empty.
                            if (! text) {
                              return "";
                            }
                          Severity: Minor
                          Found in tools/isobuild/package-source.js - About 1 hr to fix

                            Function _findAssets has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                              _findAssets({
                                sourceProcessorSet,
                                watchSet,
                                isApp,
                                sourceArch,
                            Severity: Minor
                            Found in tools/isobuild/package-source.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 initFromOptions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                              initFromOptions: function (name, options) {
                                var self = this;
                                self.name = name;
                            
                                if (options.sources && ! _.isEmpty(options.sources) &&
                            Severity: Minor
                            Found in tools/isobuild/package-source.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 loadOrderSort has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                            var loadOrderSort = function (sourceProcessorSet, arch) {
                              const isTemplate = _.memoize((filename) => {
                                const classification = sourceProcessorSet.classifyFilename(filename, arch);
                                switch (classification.type) {
                                case 'extension':
                            Severity: Minor
                            Found in tools/isobuild/package-source.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 processReadme has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                              processReadme: function () {
                                var self = this;
                                buildmessage.assertInJob();
                                if (! self.metadata.documentation) {
                                  return null;
                            Severity: Minor
                            Found in tools/isobuild/package-source.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 check has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                              check(relDir, quietly = true) {
                            
                                try {
                                  var realPath = this._realpath(relDir);
                                } catch (e) {
                            Severity: Minor
                            Found in tools/isobuild/package-source.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

                            Avoid too many return statements within this function.
                            Open

                                  return -1;
                            Severity: Major
                            Found in tools/isobuild/package-source.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                      return -1;
                              Severity: Major
                              Found in tools/isobuild/package-source.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                    return 0;
                                Severity: Major
                                Found in tools/isobuild/package-source.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                              return [];
                                  Severity: Major
                                  Found in tools/isobuild/package-source.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                          return sources;
                                    Severity: Major
                                    Found in tools/isobuild/package-source.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                              return 1;
                                      Severity: Major
                                      Found in tools/isobuild/package-source.js - About 30 mins to fix

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

                                          getPackagesToLoadFirst: function (packageMap) {
                                            var self = this;
                                            var packages = {};
                                            var processUse = function (use) {
                                              // We don't have to build weak or unordered deps first (eg they can't
                                        Severity: Minor
                                        Found in tools/isobuild/package-source.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

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

                                                if (parsedSpec.constraint) {
                                                  allConstraints[parsedSpec.package].push(parsedSpec.constraint);
                                                  if (d.constraint === null) {
                                                    d.constraint = parsedSpec.constraint;
                                                  } else if (d.constraint !== parsedSpec.constraint) {
                                        Severity: Major
                                        Found in tools/isobuild/package-source.js and 1 other location - About 2 hrs to fix
                                        tools/isobuild/package-source.js on lines 1750..1758

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

                                        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 (use.constraint) {
                                                  allConstraints[use.package].push(use.constraint);
                                        
                                                  if (d.constraint === null) {
                                                    d.constraint = use.constraint;
                                        Severity: Major
                                        Found in tools/isobuild/package-source.js and 1 other location - About 2 hrs to fix
                                        tools/isobuild/package-source.js on lines 1790..1797

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

                                        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(dependencies, use.package)) {
                                                  dependencies[use.package] = {
                                                    constraint: null,
                                                    references: []
                                                  };
                                        Severity: Major
                                        Found in tools/isobuild/package-source.js and 1 other location - About 1 hr to fix
                                        tools/isobuild/package-source.js on lines 1781..1787

                                        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

                                                if (!_.has(dependencies, parsedSpec.package)) {
                                                  dependencies[parsedSpec.package] = {
                                                    constraint: null,
                                                    references: []
                                                  };
                                        Severity: Major
                                        Found in tools/isobuild/package-source.js and 1 other location - About 1 hr to fix
                                        tools/isobuild/package-source.js on lines 1741..1747

                                        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

                                            var islib_a = (a.indexOf(files.pathSep + 'lib' + files.pathSep) !== -1 ||
                                                           a.indexOf('lib' + files.pathSep) === 0);
                                        Severity: Major
                                        Found in tools/isobuild/package-source.js and 1 other location - About 1 hr to fix
                                        tools/isobuild/package-source.js on lines 107..108

                                        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

                                            var islib_b = (b.indexOf(files.pathSep + 'lib' + files.pathSep) !== -1 ||
                                                           b.indexOf('lib' + files.pathSep) === 0);
                                        Severity: Major
                                        Found in tools/isobuild/package-source.js and 1 other location - About 1 hr to fix
                                        tools/isobuild/package-source.js on lines 105..106

                                        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

                                        There are no issues that match your filters.

                                        Category
                                        Status