bemusic/bemuse

View on GitHub
common/scripts/install-run.js

Summary

Maintainability
F
4 days
Test Coverage

File install-run.js has 395 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See the @microsoft/rush package's LICENSE file for license information.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
Severity: Minor
Found in common/scripts/install-run.js - About 5 hrs to fix

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

    function _copyAndTrimNpmrcFile(logger, sourceNpmrcPath, targetNpmrcPath) {
        logger.info(`Transforming ${sourceNpmrcPath}`); // Verbose
        logger.info(`  --> "${targetNpmrcPath}"`);
        let npmrcFileLines = fs.readFileSync(sourceNpmrcPath).toString().split('\n');
        npmrcFileLines = npmrcFileLines.map((line) => (line || '').trim());
    Severity: Minor
    Found in common/scripts/install-run.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 installAndRun has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function installAndRun(logger, packageName, packageVersion, packageBinName, packageBinArgs, lockFilePath = process.env[INSTALL_RUN_LOCKFILE_PATH_VARIABLE]) {
        const rushJsonFolder = findRushJsonFolder();
        const rushCommonFolder = path.join(rushJsonFolder, 'common');
        const rushTempFolder = _getRushTempFolder(rushCommonFolder);
        const packageInstallFolder = _ensureAndJoinPath(rushTempFolder, 'install-run', `${packageName}@${packageVersion}`);
    Severity: Minor
    Found in common/scripts/install-run.js - About 1 hr to fix

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

      function _resolvePackageVersion(logger, rushCommonFolder, { name, version }) {
          if (!version) {
              version = '*'; // If no version is specified, use the latest version
          }
          if (version.match(/^[a-zA-Z0-9\-\+\.]+$/)) {
      Severity: Minor
      Found in common/scripts/install-run.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 _copyAndTrimNpmrcFile has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function _copyAndTrimNpmrcFile(logger, sourceNpmrcPath, targetNpmrcPath) {
          logger.info(`Transforming ${sourceNpmrcPath}`); // Verbose
          logger.info(`  --> "${targetNpmrcPath}"`);
          let npmrcFileLines = fs.readFileSync(sourceNpmrcPath).toString().split('\n');
          npmrcFileLines = npmrcFileLines.map((line) => (line || '').trim());
      Severity: Minor
      Found in common/scripts/install-run.js - About 1 hr to fix

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

        function installAndRun(logger, packageName, packageVersion, packageBinName, packageBinArgs, lockFilePath = process.env[INSTALL_RUN_LOCKFILE_PATH_VARIABLE]) {
            const rushJsonFolder = findRushJsonFolder();
            const rushCommonFolder = path.join(rushJsonFolder, 'common');
            const rushTempFolder = _getRushTempFolder(rushCommonFolder);
            const packageInstallFolder = _ensureAndJoinPath(rushTempFolder, 'install-run', `${packageName}@${packageVersion}`);
        Severity: Minor
        Found in common/scripts/install-run.js - About 55 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

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

        function findRushJsonFolder() {
            if (!_rushJsonFolder) {
                let basePath = __dirname;
                let tempPath = __dirname;
                do {
        Severity: Minor
        Found in common/scripts/install-run.js - About 55 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

        Function installAndRun has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function installAndRun(logger, packageName, packageVersion, packageBinName, packageBinArgs, lockFilePath = process.env[INSTALL_RUN_LOCKFILE_PATH_VARIABLE]) {
        Severity: Minor
        Found in common/scripts/install-run.js - About 45 mins to fix

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

          var __importStar = (this && this.__importStar) || function (mod) {
              if (mod && mod.__esModule) return mod;
              var result = {};
              if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
              __setModuleDefault(result, mod);
          Severity: Minor
          Found in common/scripts/install-run.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 getNpmPath has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function getNpmPath() {
              if (!_npmPath) {
                  try {
                      if (os.platform() === 'win32') {
                          // We're on Windows
          Severity: Minor
          Found in common/scripts/install-run.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

          Avoid deeply nested control flow statements.
          Open

                              if (!process.env[environmentVariableName]) {
                                  // No, so trim this line
                                  lineShouldBeTrimmed = true;
                                  break;
                              }
          Severity: Major
          Found in common/scripts/install-run.js - About 45 mins to fix

            Function _installPackage has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            function _installPackage(logger, packageInstallFolder, name, version, command) {
            Severity: Minor
            Found in common/scripts/install-run.js - About 35 mins to fix

              Function __createBinding has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
                  if (k2 === undefined) k2 = k;
                  var desc = Object.getOwnPropertyDescriptor(m, k);
                  if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
                    desc = { enumerable: true, get: function() { return m[k]; } };
              Severity: Minor
              Found in common/scripts/install-run.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

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

              var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
                  if (k2 === undefined) k2 = k;
                  var desc = Object.getOwnPropertyDescriptor(m, k);
                  if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
                    desc = { enumerable: true, get: function() { return m[k]; } };
              Severity: Major
              Found in common/scripts/install-run.js and 1 other location - About 1 day to fix
              common/scripts/install-run-rush.js on lines 4..14

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

              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

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

              var __importStar = (this && this.__importStar) || function (mod) {
                  if (mod && mod.__esModule) return mod;
                  var result = {};
                  if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
                  __setModuleDefault(result, mod);
              Severity: Major
              Found in common/scripts/install-run.js and 1 other location - About 4 hrs to fix
              common/scripts/install-run-rush.js on lines 20..26

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

              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

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

              var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
                  Object.defineProperty(o, "default", { enumerable: true, value: v });
              }) : function(o, v) {
                  o["default"] = v;
              });
              Severity: Major
              Found in common/scripts/install-run.js and 1 other location - About 2 hrs to fix
              common/scripts/install-run-rush.js on lines 15..19

              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

              There are no issues that match your filters.

              Category
              Status