meteor/meteor

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

Summary

Maintainability
F
6 days
Test Coverage

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

// These commands deal with aggregating local package data with the information
// contained in the Meteor Package Server. They also deal with presenting this
// to the user in various human or machine-readable ways.
var _ = require('underscore');
var buildmessage = require('../utils/buildmessage.js');
Severity: Major
Found in tools/cli/commands-packages-query.js - About 2 days to fix

    Function _displayPackage has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      _displayPackage: function (data) {
        var self = this;
        var defaultVersion = data.defaultVersion;
    
        // Every package has a name. Some packages have a homepage.
    Severity: Major
    Found in tools/cli/commands-packages-query.js - About 3 hrs to fix

      Function _collectPackageData has 75 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _collectPackageData: function () {
          var self = this;
          var data = {
            name: self.metaRecord.name,
            maintainers: _.pluck(self.metaRecord.maintainers, "username"),
      Severity: Major
      Found in tools/cli/commands-packages-query.js - About 3 hrs to fix

        Function _displayPackage has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

          _displayPackage: function (data) {
            var self = this;
            var defaultVersion = data.defaultVersion;
        
            // Every package has a name. Some packages have a homepage.
        Severity: Minor
        Found in tools/cli/commands-packages-query.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 formatHiddenVersions has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        var formatHiddenVersions = function (hiddenVersions, oldestShownVersion) {
          // An array of strings, listing the reasons why some versions were hidden.
          var reasons = [];
          // Use our information about hidden versions to figure what reasons we
          // actually want to return to the user.
        Severity: Minor
        Found in tools/cli/commands-packages-query.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 _displayVersion has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _displayVersion: function (data) {
            var self = this;
            Console.info(
                data.name + "@" + data.version,
                Console.options({ bulletPoint: "Package: " }));
        Severity: Major
        Found in tools/cli/commands-packages-query.js - About 2 hrs to fix

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

            _getOfficialVersion: function (versionRecord) {
              var self = this;
              var version = versionRecord.version;
              var name = self.name;
              var data = {
          Severity: Minor
          Found in tools/cli/commands-packages-query.js - About 1 hr to fix

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

              _collectPackageData: function () {
                var self = this;
                var data = {
                  name: self.metaRecord.name,
                  maintainers: _.pluck(self.metaRecord.maintainers, "username"),
            Severity: Minor
            Found in tools/cli/commands-packages-query.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 _displayVersion has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              _displayVersion: function (data) {
                var self = this;
                Console.info(
                    data.name + "@" + data.version,
                    Console.options({ bulletPoint: "Package: " }));
            Severity: Minor
            Found in tools/cli/commands-packages-query.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 _displayAllReleaseVersions has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              _displayAllReleaseVersions: function (versions) {
                var self = this;
                var columnOpts = { indent: 2, ignoreWidth: true };
                // If we don't have any versions, then there is nothing to display.
                if (! versions) { return; }
            Severity: Minor
            Found in tools/cli/commands-packages-query.js - About 1 hr to fix

              Function _displayRelease has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                _displayRelease: function (data) {
                  var self = this;
              
                  Console.info("Release:",  data.track);
                  // There is no such thing as a local release, which means all releases have
              Severity: Minor
              Found in tools/cli/commands-packages-query.js - About 1 hr to fix

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

                var formatHiddenVersions = function (hiddenVersions, oldestShownVersion) {
                  // An array of strings, listing the reasons why some versions were hidden.
                  var reasons = [];
                  // Use our information about hidden versions to figure what reasons we
                  // actually want to return to the user.
                Severity: Minor
                Found in tools/cli/commands-packages-query.js - About 1 hr to fix

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

                    _getLocalVersion: function (localRecord) {
                      var self = this;
                      var data =  {
                        name: self.name,
                        summary: localRecord.description,
                  Severity: Minor
                  Found in tools/cli/commands-packages-query.js - About 1 hr to fix

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

                      _getReleaseData: function () {
                        var self = this;
                        var data = {
                          track: self.metaRecord.name,
                          maintainers: _.pluck(self.metaRecord.maintainers, "username")
                    Severity: Minor
                    Found in tools/cli/commands-packages-query.js - About 1 hr to fix

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

                        var filterBroken = function (match, isRelease, name) {
                          // If the package does not match, or it is not a package at all or if we
                          // don't want to filter anyway, we do not care.
                          if (!match || isRelease) {
                            return match;
                      Severity: Minor
                      Found in tools/cli/commands-packages-query.js - About 1 hr to fix

                        Function _displayRelease has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          _displayRelease: function (data) {
                            var self = this;
                        
                            Console.info("Release:",  data.track);
                            // There is no such thing as a local release, which means all releases have
                        Severity: Minor
                        Found in tools/cli/commands-packages-query.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 PackageQuery has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        var PackageQuery = function (options) {
                          var self = this;
                        
                          // This is the record in the packages collection. It contains things like
                          // maintainers, and the package homepage.
                        Severity: Minor
                        Found in tools/cli/commands-packages-query.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 false;
                        Severity: Major
                        Found in tools/cli/commands-packages-query.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

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

                            Avoid too many return statements within this function.
                            Open

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

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

                                _getOfficialVersion: function (versionRecord) {
                                  var self = this;
                                  var version = versionRecord.version;
                                  var name = self.name;
                                  var data = {
                              Severity: Minor
                              Found in tools/cli/commands-packages-query.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 (data.exports && ! data.exports.isEmpty()) {
                                    Console.info(
                                      data["exports"].getConsoleStr(),
                                      Console.options({ bulletPoint: "Exports: " }));
                                  }
                              Severity: Major
                              Found in tools/cli/commands-packages-query.js and 1 other location - About 1 hr to fix
                              tools/cli/commands-packages-query.js on lines 794..798

                              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 (data.implies && ! data.implies.isEmpty()) {
                                    Console.info(
                                      data["implies"].getConsoleStr(),
                                      Console.options({ bulletPoint: "Implies: " }));
                                  }
                              Severity: Major
                              Found in tools/cli/commands-packages-query.js and 1 other location - About 1 hr to fix
                              tools/cli/commands-packages-query.js on lines 789..793

                              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 (vr) {
                                        matchingReleases.push({
                                          name: track,
                                          description: vr.description,
                                          latestVersion: vr.version,
                              Severity: Major
                              Found in tools/cli/commands-packages-query.js and 1 other location - About 1 hr to fix
                              tools/cli/commands-packages-query.js on lines 1607..1614

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

                              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 (vr) {
                                        matchingPackages.push({
                                          name: pack,
                                          description: vr.description,
                                          latestVersion: vr.version,
                              Severity: Major
                              Found in tools/cli/commands-packages-query.js and 1 other location - About 1 hr to fix
                              tools/cli/commands-packages-query.js on lines 1620..1627

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

                              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 (!_.isEqual(matchingPackages, [])) {
                                  output = true;
                                  Console.info("Matching packages:");
                                  utils.printPackageList(matchingPackages);
                                }
                              Severity: Minor
                              Found in tools/cli/commands-packages-query.js and 1 other location - About 40 mins to fix
                              tools/cli/commands-packages-query.js on lines 1648..1652

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

                              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 (!_.isEqual(matchingReleases, [])) {
                                  output = true;
                                  Console.info("Matching releases:");
                                  utils.printPackageList(matchingReleases);
                                }
                              Severity: Minor
                              Found in tools/cli/commands-packages-query.js and 1 other location - About 40 mins to fix
                              tools/cli/commands-packages-query.js on lines 1642..1646

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

                              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