meteor/meteor

View on GitHub
packages/package-version-parser/package-version-parser.js

Summary

Maintainability
D
2 days
Test Coverage

File package-version-parser.js has 291 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var inTool = typeof Package === "undefined";

// Provided by dev_bundle/server-lib/node_modules/semver.
var semver = inTool
  ? module.parent.require("semver")
Severity: Minor
Found in packages/package-version-parser/package-version-parser.js - About 3 hrs to fix

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

    var PV = function (versionString) {
      if (! (typeof versionString === 'string')) {
        throw new Error("Invalid PackageVersion argument: " + versionString);
      }
      if (! versionString) {
    Severity: Major
    Found in packages/package-version-parser/package-version-parser.js - About 2 hrs to fix

      Function PV has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      var PV = function (versionString) {
        if (! (typeof versionString === 'string')) {
          throw new Error("Invalid PackageVersion argument: " + versionString);
        }
        if (! versionString) {
      Severity: Minor
      Found in packages/package-version-parser/package-version-parser.js - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

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

      PV.validatePackageName = function (packageName, options) {
        options = options || {};
      
        var badChar = packageName.match(/[^a-z0-9:.\-]/);
        if (badChar) {
      Severity: Minor
      Found in packages/package-version-parser/package-version-parser.js - About 1 hr to fix

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

        PV.PackageConstraint = function (part1, part2) {
          if ((typeof part1 !== "string") ||
              (part2 && (typeof part2 !== "string") &&
               ! (part2 instanceof PV.VersionConstraint))) {
            throw new Error("constraintString must be a string");
        Severity: Minor
        Found in packages/package-version-parser/package-version-parser.js - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

        PV.PackageConstraint = function (part1, part2) {
          if ((typeof part1 !== "string") ||
              (part2 && (typeof part2 !== "string") &&
               ! (part2 instanceof PV.VersionConstraint))) {
            throw new Error("constraintString must be a string");
        Severity: Minor
        Found in packages/package-version-parser/package-version-parser.js - About 1 hr to fix

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

          var prereleaseIdentifierToFraction = function (prerelease) {
            if (prerelease.length === 0)
              return 0;
          
            return prerelease.reduce(function (memo, part, index) {
          Severity: Minor
          Found in packages/package-version-parser/package-version-parser.js - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

          PV.validatePackageName = function (packageName, options) {
            options = options || {};
          
            var badChar = packageName.match(/[^a-z0-9:.\-]/);
            if (badChar) {
          Severity: Minor
          Found in packages/package-version-parser/package-version-parser.js - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

          function parseSimpleConstraint(constraintString) {
            if (! constraintString) {
              throw new Error("Non-empty string required");
            }
          
          
          Severity: Minor
          Found in packages/package-version-parser/package-version-parser.js - About 1 hr to fix

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

            PV.compare = function (versionOne, versionTwo) {
              var v1 = versionOne;
              if (typeof v1 === 'string') {
                v1 = PV.parse(v1);
              }
            Severity: Minor
            Found in packages/package-version-parser/package-version-parser.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 parseSimpleConstraint has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            function parseSimpleConstraint(constraintString) {
              if (! constraintString) {
                throw new Error("Non-empty string required");
              }
            
            
            Severity: Minor
            Found in packages/package-version-parser/package-version-parser.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

            There are no issues that match your filters.

            Category
            Status