deps/npm/lib/cache/add-remote-git.js

Summary

Maintainability
D
1 day
Test Coverage

File add-remote-git.js has 368 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var assert = require('assert')
var crypto = require('crypto')
var fs = require('graceful-fs')
var path = require('path')
var url = require('url')
Severity: Minor
Found in deps/npm/lib/cache/add-remote-git.js - About 4 hrs to fix

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

    function checkoutTreeish (from, resolvedURL, resolvedTreeish, tmpdir, cb) {
      var args = ['checkout', resolvedTreeish]
      git.whichAndExec(
        args,
        { cwd: tmpdir, env: gitEnv() },
    Severity: Minor
    Found in deps/npm/lib/cache/add-remote-git.js - About 1 hr to fix

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

      function resolveHead (from, cloneURL, treeish, cachedRemote, cb) {
        log.verbose('resolveHead', from, 'original treeish:', treeish)
        var args = ['rev-list', '-n1', treeish]
        git.whichAndExec(
          args,
      Severity: Minor
      Found in deps/npm/lib/cache/add-remote-git.js - About 1 hr to fix

        Function addRemoteGit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function addRemoteGit (uri, _cb) {
          assert(typeof uri === 'string', 'must have git URL')
          assert(typeof _cb === 'function', 'must have callback')
          var cb = dezalgo(_cb)
        
        
        Severity: Minor
        Found in deps/npm/lib/cache/add-remote-git.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 mirrorRemote has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function mirrorRemote (from, cloneURL, treeish, cachedRemote, silent, cb) {
          mkdir(cachedRemote, function (er) {
            if (er) return cb(er)
        
            var args = [
        Severity: Minor
        Found in deps/npm/lib/cache/add-remote-git.js - About 1 hr to fix

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

          function tryClone (from, combinedURL, silent, cb) {
            log.silly('tryClone', 'cloning', from, 'via', combinedURL)
          
            var normalized = normalizeGitUrl(combinedURL)
            var cloneURL = normalized.url
          Severity: Minor
          Found in deps/npm/lib/cache/add-remote-git.js - About 1 hr to fix

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

            function mirrorRemote (from, cloneURL, treeish, cachedRemote, silent, cb) {
            Severity: Minor
            Found in deps/npm/lib/cache/add-remote-git.js - About 45 mins to fix

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

              function cloneResolved (from, resolvedURL, resolvedTreeish, cachedRemote, tmpdir, cb) {
              Severity: Minor
              Found in deps/npm/lib/cache/add-remote-git.js - About 45 mins to fix

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

                function resolveHead (from, cloneURL, treeish, cachedRemote, cb) {
                Severity: Minor
                Found in deps/npm/lib/cache/add-remote-git.js - About 35 mins to fix

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

                  function resetRemote (from, cloneURL, treeish, cachedRemote, cb) {
                  Severity: Minor
                  Found in deps/npm/lib/cache/add-remote-git.js - About 35 mins to fix

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

                    function validateExistingRemote (from, cloneURL, treeish, cachedRemote, cb) {
                    Severity: Minor
                    Found in deps/npm/lib/cache/add-remote-git.js - About 35 mins to fix

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

                      function updateRemote (from, cloneURL, treeish, cachedRemote, cb) {
                      Severity: Minor
                      Found in deps/npm/lib/cache/add-remote-git.js - About 35 mins to fix

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

                        function setPermissions (from, cloneURL, treeish, cachedRemote, cb) {
                        Severity: Minor
                        Found in deps/npm/lib/cache/add-remote-git.js - About 35 mins to fix

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

                          function checkoutTreeish (from, resolvedURL, resolvedTreeish, tmpdir, cb) {
                          Severity: Minor
                          Found in deps/npm/lib/cache/add-remote-git.js - About 35 mins to fix

                            There are no issues that match your filters.

                            Category
                            Status