git-p4.py

Summary

Maintainability
F
1 mo
Test Coverage

File git-p4.py has 3465 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
#
# git-p4.py -- A tool for bidirectional operation between a Perforce depot and git.
#
# Author: Simon Hausmann <simon@lst.de>
Severity: Major
Found in git-p4.py - About 1 wk to fix

    Function applyCommit has a Cognitive Complexity of 160 (exceeds 5 allowed). Consider refactoring.
    Open

        def applyCommit(self, id):
            """Apply one commit, return True if it succeeded."""
    
            print("Applying", read_pipe(["git", "show", "-s",
                                         "--format=format:%h %s", id]))
    Severity: Minor
    Found in git-p4.py - About 3 days 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 run has a Cognitive Complexity of 131 (exceeds 5 allowed). Consider refactoring.
    Open

        def run(self, args):
            if len(args) == 0:
                self.master = currentGitBranch()
            elif len(args) == 1:
                self.master = args[0]
    Severity: Minor
    Found in git-p4.py - About 2 days 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 run has a Cognitive Complexity of 118 (exceeds 5 allowed). Consider refactoring.
    Open

        def run(self, args):
            if self.importIntoRemotes:
                self.refPrefix = "refs/remotes/p4/"
            else:
                self.refPrefix = "refs/heads/p4/"
    Severity: Minor
    Found in git-p4.py - About 2 days 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 importChanges has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
    Open

        def importChanges(self, changes, origin_revision=0):
            cnt = 1
            for change in changes:
                description = p4_describe(change)
                self.updateOptionDict(description)
    Severity: Minor
    Found in git-p4.py - About 1 day 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 p4CmdList has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
    Open

    def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None, skip_info=False,
            errors_as_exceptions=False, *k, **kw):
    
        cmd = p4_build_cmd(["-G"] + cmd)
        if verbose:
    Severity: Minor
    Found in git-p4.py - About 1 day 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 importRevisions has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

        def importRevisions(self, args, branch_arg_given):
            changes = []
    
            if len(self.changesFile) > 0:
                with open(self.changesFile) as f:
    Severity: Minor
    Found in git-p4.py - About 7 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 metadata_stream_to_writable_bytes has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

    def metadata_stream_to_writable_bytes(s):
        encodingStrategy = gitConfig('git-p4.metadataDecodingStrategy') or defaultMetadataDecodingStrategy
        fallbackEncoding = gitConfig('git-p4.metadataFallbackEncoding') or defaultFallbackMetadataEncoding
        if not isinstance(s, bytes):
            return s.encode('utf_8')
    Severity: Minor
    Found in git-p4.py - 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 importP4Labels has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

        def importP4Labels(self, stream, p4Labels):
            """Import p4 labels as git tags. A direct mapping does not exist, so
               assume that if all the files are at the same revision then we can
               use that, or it's something more complicated we should just ignore.
               """
    Severity: Minor
    Found in git-p4.py - About 5 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 commit has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

        def commit(self, details, files, branch, parent="", allow_empty=False):
            epoch = details["time"]
            author = details["user"]
            jobs = self.extractJobsFromCommit(details)
    
    
    Severity: Minor
    Found in git-p4.py - About 5 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 exportGitTags has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

        def exportGitTags(self, gitTags):
            """Export git tags as p4 labels. Create a p4 label and then tag with
               that.
               """
    
    
    Severity: Minor
    Found in git-p4.py - About 5 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 p4ChangesForPaths has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

    def p4ChangesForPaths(depotPaths, changeRange, requestedBlockSize):
        assert depotPaths
    
        # Parse the change range into start and end. Try to find integer
        # revision ranges as these can be broken up into blocks to avoid
    Severity: Minor
    Found in git-p4.py - About 5 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 getBranchMapping has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        def getBranchMapping(self):
            lostAndFoundBranches = set()
    
            user = gitConfig("git-p4.branchUser")
    
    
    Severity: Minor
    Found in git-p4.py - About 4 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

    P4Sync has 37 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class P4Sync(Command, P4UserMap):
    
        def __init__(self):
            Command.__init__(self)
            P4UserMap.__init__(self)
    Severity: Minor
    Found in git-p4.py - About 4 hrs to fix

      Function streamP4FilesCb has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          def streamP4FilesCb(self, marshalled):
              """Handle another chunk of streaming data."""
      
              # catch p4 errors and complain
              err = None
      Severity: Minor
      Found in git-p4.py - About 4 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 prepareSubmitTemplate has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          def prepareSubmitTemplate(self, changelist=None):
              """Run "p4 change -o" to grab a change specification template.
      
                 This does not use "p4 -G", as it is nice to keep the submission
                 template in original order, since a human might edit it.
      Severity: Minor
      Found in git-p4.py - About 4 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 createOrUpdateBranchesFromOrigin has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

      def createOrUpdateBranchesFromOrigin(localRefPrefix="refs/remotes/p4/", silent=True):
          if not silent:
              print("Creating/updating branch(es) in %s based on origin branch(es)"
                     % localRefPrefix)
      
      
      Severity: Minor
      Found in git-p4.py - About 4 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 main has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      def main():
          if len(sys.argv[1:]) == 0:
              printUsage(commands.keys())
              sys.exit(2)
      
      
      Severity: Minor
      Found in git-p4.py - About 3 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 streamOneP4File has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          def streamOneP4File(self, file, contents):
              """Output one file from the P4 stream.
      
                 This is a helper for streamP4Files().
                 """
      Severity: Minor
      Found in git-p4.py - About 3 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 gitCommitByP4Change has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def gitCommitByP4Change(self, ref, change):
              if self.verbose:
                  print("looking in ref " + ref + " for change %s using bisect..." % change)
      
              earliestCommit = ""
      Severity: Minor
      Found in git-p4.py - About 3 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 prepareLogMessage has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def prepareLogMessage(self, template, message, jobs):
              """Edits the template returned from "p4 change -o" to insert the
                 message in the Description field, and the jobs text in the Jobs
                 field.
                 """
      Severity: Minor
      Found in git-p4.py - About 3 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 run has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def run(self, args):
              if len(args) < 1:
                  return False
      
              if self.keepRepoPath and not self.cloneDestination:
      Severity: Minor
      Found in git-p4.py - 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 findUpstreamBranchPoint has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      def findUpstreamBranchPoint(head="HEAD"):
          branches = p4BranchesInGit()
          # map from depot-path to branch name
          branchByDepotPath = {}
          for branch in branches.keys():
      Severity: Minor
      Found in git-p4.py - 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 stripRepoPath has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def stripRepoPath(self, path, prefixes):
              """When streaming files, this is called to map a p4 depot path to where
                 it should go in git.  The prefixes are either self.depotPaths, or
                 self.branchPrefixes in the case of branch detection.
                 """
      Severity: Minor
      Found in git-p4.py - 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 p4_check_access has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def p4_check_access(min_expiration=1):
          """Check if we can access Perforce - account still logged in."""
      
          results = p4CmdList(["login", "-s"])
      
      
      Severity: Minor
      Found in git-p4.py - 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 p4Where has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

      def p4Where(depotPath):
          if not depotPath.endswith("/"):
              depotPath += "/"
          depotPathLong = depotPath + "..."
          outputList = p4CmdList(["where", depotPathLong])
      Severity: Minor
      Found in git-p4.py - 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 findShadowedFiles has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def findShadowedFiles(self, files, change):
              """Perforce allows you commit files and directories with the same name,
                 so you could have files //depot/foo and //depot/foo/bar both checked
                 in.  A p4 sync of a repository in this state fails.  Deleting one of
                 the files recovers the repository.
      Severity: Minor
      Found in git-p4.py - 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 importHeadRevision has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def importHeadRevision(self, revision):
              print("Doing initial import of %s from revision %s into %s" % (' '.join(self.depotPaths), revision, self.branch))
      
              details = {}
              details["user"] = "git perforce import user"
      Severity: Minor
      Found in git-p4.py - 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 splitFilesIntoBranches has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def splitFilesIntoBranches(self, commit):
              """Look at each depotFile in the commit to figure out to what branch it
                 belongs.
                 """
      
      
      Severity: Minor
      Found in git-p4.py - 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 update_client_spec_path_cache has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def update_client_spec_path_cache(self, files):
              """Caching file paths by "p4 where" batch query."""
      
              # List depot file paths exclude that already cached
              fileArgs = [f['path'] for f in files if decode_path(f['path']) not in self.client_spec_path_cache]
      Severity: Minor
      Found in git-p4.py - 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 processContent has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def processContent(self, git_mode, relPath, contents):
              """Processes the content of git fast import. This method decides if a
                 file is stored in the large file system and handles all necessary
                 steps.
                 """
      Severity: Minor
      Found in git-p4.py - 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 streamP4Files has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def streamP4Files(self, files):
              """Stream directly from "p4 files" into "git fast-import."""
      
              filesForCommit = []
              filesToRead = []
      Severity: Minor
      Found in git-p4.py - 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 get_diff_description has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_diff_description(self, editedFiles, filesToAdd, symlinks):
              # diff
              if "P4DIFF" in os.environ:
                  del(os.environ["P4DIFF"])
              diff = ""
      Severity: Minor
      Found in git-p4.py - 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 applyCommit has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def applyCommit(self, id):
              """Apply one commit, return True if it succeeded."""
      
              print("Applying", read_pipe(["git", "show", "-s",
                                           "--format=format:%h %s", id]))
      Severity: Minor
      Found in git-p4.py - About 1 hr to fix

        Function run has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def run(self, args):
                if len(args) == 0:
                    self.master = currentGitBranch()
                elif len(args) == 1:
                    self.master = args[0]
        Severity: Minor
        Found in git-p4.py - About 1 hr to fix

          Function __init__ has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def __init__(self):
                  Command.__init__(self)
                  P4UserMap.__init__(self)
                  self.options = [
                          optparse.make_option("--branch", dest="branch"),
          Severity: Minor
          Found in git-p4.py - About 1 hr to fix

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

                def getLabels(self):
                    """Build a dictionary of changelists and labels, for "detect-labels"
                       option.
                       """
            
            
            Severity: Minor
            Found in git-p4.py - 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 extractSettingsGitLog has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            def extractSettingsGitLog(log):
                values = {}
                for line in log.split("\n"):
                    line = line.strip()
                    m = re.search(r"^ *\[git-p4: (.*)\]$", line)
            Severity: Minor
            Found in git-p4.py - 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 modifyChangelistUser has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def modifyChangelistUser(self, changelist, newUser):
                    """Fixup the user field of a changelist after it has been submitted."""
                    changes = p4CmdList(["change", "-o", changelist])
                    if len(changes) != 1:
                        die("Bad output from p4 change modifying %s to user %s" %
            Severity: Minor
            Found in git-p4.py - 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 decode_path has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            def decode_path(path):
                """Decode a given string (bytes or otherwise) using configured path
                   encoding options.
                   """
            
            
            Severity: Minor
            Found in git-p4.py - 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 isPathWanted has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def isPathWanted(self, path):
                    for p in self.cloneExclude:
                        if p.endswith("/"):
                            if p4PathStartsWith(path, p):
                                return False
            Severity: Minor
            Found in git-p4.py - 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 commit has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def commit(self, details, files, branch, parent="", allow_empty=False):
                    epoch = details["time"]
                    author = details["user"]
                    jobs = self.extractJobsFromCommit(details)
            
            
            Severity: Minor
            Found in git-p4.py - About 1 hr to fix

              Function p4CmdList has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None, skip_info=False,
              Severity: Major
              Found in git-p4.py - About 1 hr to fix

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

                    def append(self, view_line):
                        """Parse a view line, splitting it into depot and client sides.  Append
                           to self.mappings, preserving order.  This is only needed for tag
                           creation.
                           """
                Severity: Minor
                Found in git-p4.py - 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 getUserMapFromPerforceServer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def getUserMapFromPerforceServer(self):
                        if self.userMapFromPerforceServer:
                            return
                        self.users = {}
                        self.emails = {}
                Severity: Minor
                Found in git-p4.py - 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 canChangeChangelists has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def canChangeChangelists(self):
                        """Check to see if we have p4 admin or super-user permissions, either
                           of which are required to modify changelists.
                           """
                        results = p4CmdList(["protects", self.depotPath])
                Severity: Minor
                Found in git-p4.py - 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

                Avoid deeply nested control flow statements.
                Open

                                        for (prev, cur) in zip(self.previousDepotPaths, depotPaths):
                                            prev_list = prev.split("/")
                                            cur_list = cur.split("/")
                                            for i in range(0, min(len(cur_list), len(prev_list))):
                                                if cur_list[i] != prev_list[i]:
                Severity: Major
                Found in git-p4.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if len(cdup) > 0:
                                          chdir(cdup)
                  
                  
                  Severity: Major
                  Found in git-p4.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if not m:
                                            m = re.search(r'Request too large \(over (\d+)\)', data)
                    
                    
                    Severity: Major
                    Found in git-p4.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if not self.silent:
                                                  print("p4 branch %s defines a mapping from %s to %s" % (info["branch"], source, destination))
                                                  print("but there exists another mapping from %s to %s already!" % (self.knownBranches[destination], destination))
                                              continue
                      Severity: Major
                      Found in git-p4.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                    if parent == branch:
                                                        parent = ""
                                                    else:
                                                        fullBranch = self.projectName + branch
                                                        if fullBranch not in self.p4BranchesInGit:
                        Severity: Major
                        Found in git-p4.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                      if self.verbose:
                                                          print("Parent of %s not found. Committing into head of %s" % (branch, parent))
                                                      self.commit(description, filesForCommit, branch, parent)
                          Severity: Major
                          Found in git-p4.py - About 45 mins to fix

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

                                def searchParent(self, parent, branch, target):
                                    targetTree = read_pipe(["git", "rev-parse",
                                                            "{}^{{tree}}".format(target)]).strip()
                                    for line in read_pipe_lines(["git", "rev-list", "--format=%H %T",
                                                                 "--no-merges", parent]):
                            Severity: Minor
                            Found in git-p4.py - 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 self.verbose:
                                                            print("Creating temporary branch: " + tempBranch)
                                                        self.commit(description, filesForCommit, tempBranch)
                            Severity: Major
                            Found in git-p4.py - About 45 mins to fix

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

                              def p4_build_cmd(cmd):
                                  """Build a suitable p4 command line.
                              
                                     This consolidates building and returning a p4 command line into one
                                     location. It means that hooking into the environment, or other
                              Severity: Minor
                              Found in git-p4.py - 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 m:
                                                      limit = int(m.group(1))
                                                      raise P4RequestSizeException(exitCode, result, limit)
                              
                              
                              Severity: Major
                              Found in git-p4.py - About 45 mins to fix

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

                                    def edit_template(self, template_file):
                                        """Invoke the editor to let the user change the submission message.
                                
                                           Return true if okay to continue with the submit.
                                           """
                                Severity: Minor
                                Found in git-p4.py - 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 exceedsLargeFileThreshold has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def exceedsLargeFileThreshold(self, relPath, contents):
                                        if gitConfigInt('git-p4.largeFileThreshold'):
                                            contentsSize = sum(len(d) for d in contents)
                                            if contentsSize > gitConfigInt('git-p4.largeFileThreshold'):
                                                return True
                                Severity: Minor
                                Found in git-p4.py - 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 originP4Change > p4Change:
                                                        print("%s (%s) is newer than %s (%s). "
                                                               "Updating p4 branch from origin."
                                                               % (originHead, originP4Change,
                                                                  remoteHead, p4Change))
                                Severity: Major
                                Found in git-p4.py - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                          for line in read_pipe_lines(
                                                                  ["git", "diff", "%s^..%s" % (id, id), file],
                                                                  raw=True):
                                                              if regexp.search(line):
                                                                  if verbose:
                                  Severity: Major
                                  Found in git-p4.py - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                            if branch_arg_given:
                                                                raise P4CommandException("Error: branch %s does not exist." % self.branch)
                                                            else:
                                                                raise P4CommandException("Error: no branch %s; perhaps specify one with --branch." %
                                                                    self.branch)
                                    Severity: Major
                                    Found in git-p4.py - About 45 mins to fix

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

                                          def commit(self, details, files, branch, parent="", allow_empty=False):
                                      Severity: Minor
                                      Found in git-p4.py - About 35 mins to fix

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

                                        def read_pipe(c, ignore_error=False, raw=False, *k, **kw):
                                        Severity: Minor
                                        Found in git-p4.py - About 35 mins to fix

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

                                          def p4_read_pipe(c, ignore_error=False, raw=False, *k, **kw):
                                          Severity: Minor
                                          Found in git-p4.py - About 35 mins to fix

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

                                                def streamTag(self, gitStream, labelName, labelDetails, commit, epoch):
                                            Severity: Minor
                                            Found in git-p4.py - About 35 mins to fix

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

                                                  def streamTag(self, gitStream, labelName, labelDetails, commit, epoch):
                                                      """Stream a p4 tag.
                                              
                                                         Commit is either a git commit, or a fast-import mark, ":<p4commit>".
                                                         """
                                              Severity: Minor
                                              Found in git-p4.py - 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

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

                                                  def checkValidP4Users(self, commits):
                                                      """Check if any git authors cannot be mapped to p4 users."""
                                                      for id in commits:
                                                          user, email = self.p4UserForCommit(id)
                                                          if not user:
                                              Severity: Minor
                                              Found in git-p4.py - 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

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

                                              def p4BranchesInGit(branchesAreInRemotes=True):
                                                  """Find all the branches whose names start with "p4/", looking
                                                     in remotes or heads as specified by the argument.  Return
                                                     a dictionary of { branch: revision } for each one found.
                                                     The branch names are the short names, without any
                                              Severity: Minor
                                              Found in git-p4.py - 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

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

                                              def p4_describe(change, shelved=False):
                                                  """Make sure it returns a valid result by checking for the presence of
                                                     field "time".
                                              
                                                     Return a dict of the results.
                                              Severity: Minor
                                              Found in git-p4.py - 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

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

                                                  def lastP4Changelist(self):
                                                      """Get back the last changelist number submitted in this client spec.
                                              
                                                         This then gets used to patch up the username in the change. If the
                                                         same client spec is being used by multiple processes then this might
                                              Severity: Minor
                                              Found in git-p4.py - 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 escaped_bytes
                                              Severity: Major
                                              Found in git-p4.py - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                                    return False
                                                Severity: Major
                                                Found in git-p4.py - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                          return submitted
                                                  Severity: Major
                                                  Found in git-p4.py - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                                return False
                                                    Severity: Major
                                                    Found in git-p4.py - About 30 mins to fix

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

                                                          def sync_origin_only(self):
                                                              if self.syncWithOrigin:
                                                                  self.hasOrigin = originP4BranchesExist()
                                                                  if self.hasOrigin:
                                                                      if not self.silent:
                                                      Severity: Minor
                                                      Found in git-p4.py - 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

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

                                                      def extractLogMessageFromGitCommit(commit):
                                                          logMessage = ""
                                                      
                                                          # fixme: title is first line of commit, not 1st paragraph.
                                                          foundTitle = False
                                                      Severity: Minor
                                                      Found in git-p4.py - 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

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

                                                      def p4_keywords_regexp_for_type(base, type_mods):
                                                          """Given a type base and modifier, return a regexp matching the keywords
                                                             that can be expanded in the file.
                                                             """
                                                      
                                                      
                                                      Severity: Minor
                                                      Found in git-p4.py - 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

                                                      def p4_edit(f, *options):
                                                          p4_system(["edit"] + list(options) + [wildcard_encode(f)])
                                                      Severity: Minor
                                                      Found in git-p4.py and 1 other location - About 55 mins to fix
                                                      git-p4.py on lines 541..542

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

                                                      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

                                                      def p4_sync(f, *options):
                                                          p4_system(["sync"] + list(options) + [wildcard_encode(f)])
                                                      Severity: Minor
                                                      Found in git-p4.py and 1 other location - About 55 mins to fix
                                                      git-p4.py on lines 557..558

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

                                                      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 'shelved_cl' in f:
                                                                          # Handle shelved CLs using the "p4 print file@=N" syntax to print
                                                                          # the contents
                                                                          fileArg = f['path'] + encode_text_stream('@={}'.format(f['shelved_cl']))
                                                      Severity: Minor
                                                      Found in git-p4.py and 1 other location - About 35 mins to fix
                                                      git-p4.py on lines 3329..3334

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

                                                      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

                                                                  files = p4CmdList(["files"] + ["%s...@%s" % (p, change)
                                                                                                      for p in self.branchPrefixes])
                                                      Severity: Minor
                                                      Found in git-p4.py and 1 other location - About 30 mins to fix
                                                      git-p4.py on lines 3553..3555

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

                                                      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 not self.silent and not self.detectBranches:
                                                                      print("Import destination: %s" % self.branch)
                                                      Severity: Minor
                                                      Found in git-p4.py and 1 other location - About 30 mins to fix
                                                      git-p4.py on lines 4133..4134

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

                                                      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

                                                          def addLargeFile(self, relPath):
                                                              LargeFileSystem.addLargeFile(self, relPath)
                                                              self.writeToGitStream('100644', '.gitattributes', self.generateGitAttributes())
                                                      Severity: Minor
                                                      Found in git-p4.py and 1 other location - About 30 mins to fix
                                                      git-p4.py on lines 1651..1653

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

                                                      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 not self.silent and not self.detectBranches:
                                                                          print("Performing incremental import into %s git branch" % self.branch)
                                                      Severity: Minor
                                                      Found in git-p4.py and 1 other location - About 30 mins to fix
                                                      git-p4.py on lines 3993..3994

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

                                                      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

                                                                  for file in p4CmdList(["files"] +
                                                                                            ["%s...@%s" % (p, label)
                                                                                                for p in self.depotPaths]):
                                                      Severity: Minor
                                                      Found in git-p4.py and 1 other location - About 30 mins to fix
                                                      git-p4.py on lines 3512..3513

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

                                                      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

                                                          def removeLargeFile(self, relPath):
                                                              LargeFileSystem.removeLargeFile(self, relPath)
                                                              self.writeToGitStream('100644', '.gitattributes', self.generateGitAttributes())
                                                      Severity: Minor
                                                      Found in git-p4.py and 1 other location - About 30 mins to fix
                                                      git-p4.py on lines 1647..1649

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

                                                      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