meteor/meteor

View on GitHub
tools/isobuild/compiler-plugin.js

Summary

Maintainability
F
1 wk
Test Coverage

File compiler-plugin.js has 1196 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var archinfo = require('../utils/archinfo');
var buildmessage = require('../utils/buildmessage.js');
var buildPluginModule = require('./build-plugin.js');
var colonConverter = require('../utils/colon-converter.js');
var files = require('../fs/files');
Severity: Major
Found in tools/isobuild/compiler-plugin.js - About 3 days to fix

    Function computeJsOutputFilesMap has 160 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      static computeJsOutputFilesMap(sourceBatches) {
        const map = new Map;
    
        sourceBatches.forEach(batch => {
          const name = batch.unibuild.pkg.name || null;
    Severity: Major
    Found in tools/isobuild/compiler-plugin.js - About 6 hrs to fix

      Function _linkJS has 115 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _linkJS(jsResources, onCacheKey = () => {}) {
          const self = this;
          buildmessage.assertInJob();
      
          var bundleArch = self.processor.arch;
      Severity: Major
      Found in tools/isobuild/compiler-plugin.js - About 4 hrs to fix

        Function _linkJS has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

          _linkJS(jsResources, onCacheKey = () => {}) {
            const self = this;
            buildmessage.assertInJob();
        
            var bundleArch = self.processor.arch;
        Severity: Minor
        Found in tools/isobuild/compiler-plugin.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 _warnAboutMissingModules has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

          static _warnAboutMissingModules(missingModules) {
            const topLevelMissingIDs = {};
            const warnings = [];
        
            Object.keys(missingModules).forEach(id => {
        Severity: Minor
        Found in tools/isobuild/compiler-plugin.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

        InputFile has 28 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class InputFile extends buildPluginModule.InputFile {
          constructor(resourceSlot) {
            super();
            // We use underscored attributes here because this is user-visible
            // code and we don't want users to be accessing anything that we don't
        Severity: Minor
        Found in tools/isobuild/compiler-plugin.js - About 3 hrs to fix

          Function runCompilerPlugins has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            runCompilerPlugins() {
              const self = this;
              buildmessage.assertInJob();
          
              // plugin id -> {sourceProcessor, resourceSlots}
          Severity: Major
          Found in tools/isobuild/compiler-plugin.js - About 2 hrs to fix

            Function _isLazy has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

              _isLazy(options, isJavaScript) {
                let lazy = this._getOption("lazy", options);
            
                if (typeof lazy === "boolean") {
                  return lazy;
            Severity: Minor
            Found in tools/isobuild/compiler-plugin.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 _warnAboutMissingModules has 54 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              static _warnAboutMissingModules(missingModules) {
                const topLevelMissingIDs = {};
                const warnings = [];
            
                Object.keys(missingModules).forEach(id => {
            Severity: Major
            Found in tools/isobuild/compiler-plugin.js - About 2 hrs to fix

              Function constructor has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                constructor(unibuild, processor, {
                  sourceRoot,
                  linkerCacheDir,
                  scannerCacheDir,
                }) {
              Severity: Major
              Found in tools/isobuild/compiler-plugin.js - About 2 hrs to fix

                Function handleMissing has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function handleMissing(missingModules) {
                      const missingMap = new Map;
                
                      _.each(missingModules, (importInfoList, id) => {
                        const parts = id.split("/");
                Severity: Minor
                Found in tools/isobuild/compiler-plugin.js - About 1 hr to fix

                  Function addStylesheet has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    addStylesheet(options, lazyFinalizer) {
                      if (! this.sourceProcessor) {
                        throw Error("addStylesheet on non-source ResourceSlot?");
                      }
                  
                  
                  Severity: Minor
                  Found in tools/isobuild/compiler-plugin.js - About 1 hr to fix

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

                      addStylesheet(options, lazyFinalizer) {
                        if (! this.sourceProcessor) {
                          throw Error("addStylesheet on non-source ResourceSlot?");
                        }
                    
                    
                    Severity: Minor
                    Found in tools/isobuild/compiler-plugin.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 _isLazy has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      _isLazy(options, isJavaScript) {
                        let lazy = this._getOption("lazy", options);
                    
                        if (typeof lazy === "boolean") {
                          return lazy;
                    Severity: Minor
                    Found in tools/isobuild/compiler-plugin.js - About 1 hr to fix

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

                        _get(name) {
                          if (hasOwn.call(this, name)) {
                            return this[name];
                          }
                      
                      
                      Severity: Minor
                      Found in tools/isobuild/compiler-plugin.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 compileOneJsResource has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                      Open

                        compileOneJsResource(resource) {
                          const slot = this.makeResourceSlot({
                            type: "source",
                            extension: "js",
                            // Need { data, path, hash } here, at least.
                      Severity: Minor
                      Found in tools/isobuild/compiler-plugin.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 maybeWarn has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function maybeWarn(id, info) {
                            if (info.packageName) {
                              // Silence warnings generated by Meteor packages, since package
                              // authors can be trusted to test their packages, and may have
                              // different/better approaches to ensuring their dependencies are
                      Severity: Minor
                      Found in tools/isobuild/compiler-plugin.js - About 1 hr to fix

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

                          _get(name) {
                            if (hasOwn.call(this, name)) {
                              return this[name];
                            }
                        
                        
                        Severity: Minor
                        Found in tools/isobuild/compiler-plugin.js - About 1 hr to fix

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

                            compileOneJsResource(resource) {
                              const slot = this.makeResourceSlot({
                                type: "source",
                                extension: "js",
                                // Need { data, path, hash } here, at least.
                          Severity: Minor
                          Found in tools/isobuild/compiler-plugin.js - About 1 hr to fix

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

                              findControlFile(basename) {
                                let absPath = this._controlFileCache[basename];
                                if (typeof absPath === "string") {
                                  return absPath;
                                }
                            Severity: Minor
                            Found in tools/isobuild/compiler-plugin.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 constructor has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                              constructor(unibuildResourceInfo,
                                          sourceProcessor,
                                          packageSourceBatch) {
                                const self = this;
                                // XXX ideally this should be an classy object, but it's not.
                            Severity: Minor
                            Found in tools/isobuild/compiler-plugin.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 makeResourceSlot has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                              makeResourceSlot(resource) {
                                let sourceProcessor = null;
                                if (resource.type === "source") {
                                  var extension = resource.extension;
                                  if (extension === null) {
                            Severity: Minor
                            Found in tools/isobuild/compiler-plugin.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 makeResourceSlot has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              makeResourceSlot(resource) {
                                let sourceProcessor = null;
                                if (resource.type === "source") {
                                  var extension = resource.extension;
                                  if (extension === null) {
                            Severity: Minor
                            Found in tools/isobuild/compiler-plugin.js - About 1 hr to fix

                              Avoid too many return statements within this function.
                              Open

                                    return true;
                              Severity: Major
                              Found in tools/isobuild/compiler-plugin.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                    return isInImports;
                                Severity: Major
                                Found in tools/isobuild/compiler-plugin.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                      return this[name] = this._initialOptions[name];
                                  Severity: Major
                                  Found in tools/isobuild/compiler-plugin.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                        return this._controlFileCache[basename] = null;
                                    Severity: Major
                                    Found in tools/isobuild/compiler-plugin.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                return true;
                                      Severity: Major
                                      Found in tools/isobuild/compiler-plugin.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                return ! mainModule;
                                        Severity: Major
                                        Found in tools/isobuild/compiler-plugin.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                    return;
                                          Severity: Major
                                          Found in tools/isobuild/compiler-plugin.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                    return;
                                            Severity: Major
                                            Found in tools/isobuild/compiler-plugin.js - About 30 mins to fix

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

                                                finalize() {
                                                  if (this._finalizerPromise) {
                                                    this._finalizerPromise.await();
                                                  } else if (this._lazyFinalizer) {
                                                    const finalize = this._lazyFinalizer;
                                              Severity: Minor
                                              Found in tools/isobuild/compiler-plugin.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

                                                      return {
                                                        meteorInstallOptions: inputFile.meteorInstallOptions,
                                                        absModuleId: inputFile.absModuleId,
                                                        sourceMap: !! inputFile.sourceMap,
                                                        mainModule: inputFile.mainModule,
                                              Severity: Major
                                              Found in tools/isobuild/compiler-plugin.js and 1 other location - About 2 hrs to fix
                                              tools/runners/run-hmr.js on lines 329..338

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

                                              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 (! sourceProcessor) {
                                                        buildmessage.error(
                                                          `no plugin found for ${ resource.path } in ` +
                                                            `${ this.unibuild.pkg.displayName() }; a plugin for ${ filename } ` +
                                                            `was active when it was published but none is now`);
                                              Severity: Major
                                              Found in tools/isobuild/compiler-plugin.js and 1 other location - About 1 hr to fix
                                              tools/isobuild/compiler-plugin.js on lines 1193..1200

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

                                              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 (! sourceProcessor && extension !== 'js') {
                                                        buildmessage.error(
                                                          `no plugin found for ${ resource.path } in ` +
                                                            `${ this.unibuild.pkg.displayName() }; a plugin for *.${ extension } ` +
                                                            `was active when it was published but none is now`);
                                              Severity: Major
                                              Found in tools/isobuild/compiler-plugin.js and 1 other location - About 1 hr to fix
                                              tools/isobuild/compiler-plugin.js on lines 1181..1188

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

                                              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