meteor/meteor

View on GitHub
tools/cli/commands-packages.js

Summary

Maintainability
F
1 wk
Test Coverage

File commands-packages.js has 2086 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var main = require('./main.js');
var _ = require('underscore');
var files = require('../fs/files');
var buildmessage = require('../utils/buildmessage.js');
var auth = require('../meteor-services/auth.js');
Severity: Major
Found in tools/cli/commands-packages.js - About 5 days to fix

    Function maybeUpdateRelease has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

    var maybeUpdateRelease = function (options) {
      // We are only updating packages, so we are not updating the release.
      if (options["packages-only"]) {
         return 0;
      }
    Severity: Minor
    Found in tools/cli/commands-packages.js - About 6 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 maybeUpdateRelease has 141 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var maybeUpdateRelease = function (options) {
      // We are only updating packages, so we are not updating the release.
      if (options["packages-only"]) {
         return 0;
      }
    Severity: Major
    Found in tools/cli/commands-packages.js - About 5 hrs to fix

      Function messages has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        var messages = buildmessage.capture(function () {
          _.each(packagesToAdd, function (packageReq) {
            buildmessage.enterJob("adding package " + packageReq, function () {
              var constraint = utils.parsePackageConstraint(packageReq, {
                useBuildmessage: true
      Severity: Major
      Found in tools/cli/commands-packages.js - About 2 hrs to fix

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

        var updatePackageMetadata = function (packageSource, conn) {
            var name = packageSource.name;
            var version = packageSource.version;
        
            // You can't change the metadata of a record that doesn't exist.
        Severity: Minor
        Found in tools/cli/commands-packages.js - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

            if (showTree || showJson) {
              const jsonOut = showJson && {};
              const showWeak = !!options['weak'];
              const showDetails = !!options['details'];
              // Load package details of all used packages (inc. dependencies)
          Severity: Critical
          Found in tools/cli/commands-packages.js - About 1 hr to fix

            Avoid too many return statements within this function.
            Open

                return 0;
            Severity: Major
            Found in tools/cli/commands-packages.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                    return 0;
              Severity: Major
              Found in tools/cli/commands-packages.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return 0;
                Severity: Major
                Found in tools/cli/commands-packages.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return 1;
                  Severity: Major
                  Found in tools/cli/commands-packages.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                          return 1;
                    Severity: Major
                    Found in tools/cli/commands-packages.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                            return 0;
                      Severity: Major
                      Found in tools/cli/commands-packages.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return 1;
                        Severity: Major
                        Found in tools/cli/commands-packages.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                return 1;
                          Severity: Major
                          Found in tools/cli/commands-packages.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                  return 1;
                            Severity: Major
                            Found in tools/cli/commands-packages.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                return 0;
                              Severity: Major
                              Found in tools/cli/commands-packages.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                  return 0;
                                Severity: Major
                                Found in tools/cli/commands-packages.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                        return 1;
                                  Severity: Major
                                  Found in tools/cli/commands-packages.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                        return 1;
                                    Severity: Major
                                    Found in tools/cli/commands-packages.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                        return 0;
                                      Severity: Major
                                      Found in tools/cli/commands-packages.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                              return 2;
                                        Severity: Major
                                        Found in tools/cli/commands-packages.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                return 1;
                                          Severity: Major
                                          Found in tools/cli/commands-packages.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                return 1;
                                            Severity: Major
                                            Found in tools/cli/commands-packages.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                    return 2;
                                              Severity: Major
                                              Found in tools/cli/commands-packages.js - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                    return 0;
                                                Severity: Major
                                                Found in tools/cli/commands-packages.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                      return updatePackageMetadata(packageSource, conn);
                                                  Severity: Major
                                                  Found in tools/cli/commands-packages.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                      return 0;
                                                    Severity: Major
                                                    Found in tools/cli/commands-packages.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                            return 1;
                                                      Severity: Major
                                                      Found in tools/cli/commands-packages.js - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                              return 0;
                                                        Severity: Major
                                                        Found in tools/cli/commands-packages.js - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                              return 0;
                                                          Severity: Major
                                                          Found in tools/cli/commands-packages.js - About 30 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                return 1;
                                                            Severity: Major
                                                            Found in tools/cli/commands-packages.js - About 30 mins to fix

                                                              Avoid too many return statements within this function.
                                                              Open

                                                                return 0;
                                                              Severity: Major
                                                              Found in tools/cli/commands-packages.js - About 30 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                  return 0;
                                                                Severity: Major
                                                                Found in tools/cli/commands-packages.js - About 30 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                      return 1;
                                                                  Severity: Major
                                                                  Found in tools/cli/commands-packages.js - About 30 mins to fix

                                                                    Avoid too many return statements within this function.
                                                                    Open

                                                                      return 0;
                                                                    Severity: Major
                                                                    Found in tools/cli/commands-packages.js - About 30 mins to fix

                                                                      Avoid too many return statements within this function.
                                                                      Open

                                                                        return 0;
                                                                      Severity: Major
                                                                      Found in tools/cli/commands-packages.js - About 30 mins to fix

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

                                                                        var getNewerVersion = function (packageName, curVersion, whichCatalog) {
                                                                          // Check to see if there are later versions available, returning the
                                                                          // latest version if there are.
                                                                          //
                                                                          // If we are not using an rc for this package, then we are not going to
                                                                        Severity: Minor
                                                                        Found in tools/cli/commands-packages.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 (messages.hasMessages()) {
                                                                            Console.arrowError("Errors while adding packages:", 1);
                                                                            Console.printMessages(messages);
                                                                            catalogUtils.explainIfRefreshFailed();  // this is why we're not using captureAndExit
                                                                            return 1;
                                                                        Severity: Minor
                                                                        Found in tools/cli/commands-packages.js and 1 other location - About 55 mins to fix
                                                                        tools/cli/commands-packages.js on lines 2279..2284

                                                                        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 (messages.hasMessages()) {
                                                                            Console.arrowError("Errors while parsing arguments:", 1);
                                                                            Console.printMessages(messages);
                                                                            catalogUtils.explainIfRefreshFailed();  // this is why we're not using captureAndExit
                                                                            return 1;
                                                                        Severity: Minor
                                                                        Found in tools/cli/commands-packages.js and 1 other location - About 55 mins to fix
                                                                        tools/cli/commands-packages.js on lines 2292..2297

                                                                        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 (fullRecord.release) {
                                                                                  packageClient.callPackageServer(
                                                                                    conn, 'addReleaseMaintainer', name, options.add);
                                                                                } else {
                                                                                  packageClient.callPackageServer(
                                                                        Severity: Minor
                                                                        Found in tools/cli/commands-packages.js and 1 other location - About 50 mins to fix
                                                                        tools/cli/commands-packages.js on lines 2509..2515

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

                                                                        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 (fullRecord.release) {
                                                                                  packageClient.callPackageServer(
                                                                                    conn, 'removeReleaseMaintainer', name, options.remove);
                                                                                } else {
                                                                                  packageClient.callPackageServer(
                                                                        Severity: Minor
                                                                        Found in tools/cli/commands-packages.js and 1 other location - About 50 mins to fix
                                                                        tools/cli/commands-packages.js on lines 2500..2506

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

                                                                        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

                                                                              Console.info(" * " + rec.name + " " + rec.selectedVersion +
                                                                                           " (" + rec.latestVersion + " is available)");
                                                                        Severity: Minor
                                                                        Found in tools/cli/commands-packages.js and 1 other location - About 35 mins to fix
                                                                        tools/runners/run-proxy.js on lines 88..90

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

                                                                        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 {
                                                                                  plugins[id] = version;
                                                                                  Console.info(`Added Cordova plugin ${id}@${version}.`);
                                                                                  changed = true;
                                                                                }
                                                                        Severity: Minor
                                                                        Found in tools/cli/commands-packages.js and 1 other location - About 30 mins to fix
                                                                        tools/cli/commands-packages.js on lines 2164..2169

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

                                                                        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 (newId) {
                                                                                  plugins[newId] = version;
                                                                                  Console.info(`Added Cordova plugin ${newId}@${version} \
                                                                          (plugin has been renamed as part of moving to npm).`);
                                                                                  changed = true;
                                                                        Severity: Minor
                                                                        Found in tools/cli/commands-packages.js and 1 other location - About 30 mins to fix
                                                                        tools/cli/commands-packages.js on lines 2169..2173

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

                                                                        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