gitlabhq/grit

View on GitHub

Showing 88 of 88 total issues

File repository.rb has 589 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'grit/git-ruby/internal/raw_object'
require 'grit/git-ruby/internal/pack'
require 'grit/git-ruby/internal/loose'
require 'grit/git-ruby/git_object'

Severity: Major
Found in lib/grit/git-ruby/repository.rb - About 1 day to fix

    Class Repo has 66 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Repo
        include POSIX::Spawn
    
        DAEMON_EXPORT_FILE = 'git-daemon-export-ok'
        BATCH_PARSERS      = {
    Severity: Major
    Found in lib/grit/repo.rb - About 1 day to fix

      Method diff has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
      Open

            def diff(commit1, commit2, options = {})
              patch = ''
      
              commit_obj1 = get_object_by_sha1(commit1)
              tree1 = commit_obj1.tree
      Severity: Minor
      Found in lib/grit/git-ruby/repository.rb - 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

      File repo.rb has 453 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module Grit
        class Repo
          include POSIX::Spawn
      
          DAEMON_EXPORT_FILE = 'git-daemon-export-ok'
      Severity: Minor
      Found in lib/grit/repo.rb - About 6 hrs to fix

        Method walk_log has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
        Open

              def walk_log(sha, opts, total_size = 0)
                return [] if @already_searched[sha] # to prevent rechecking branches
                @already_searched[sha] = true
        
                array = []
        Severity: Minor
        Found in lib/grit/git-ruby/repository.rb - 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

        Method ls_tree_path has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
        Open

              def ls_tree_path(sha, path, append = nil)
                tree = get_raw_tree(sha)
                if path =~ /\//
                  paths = path.split('/')
                  last = path[path.size - 1, 1]
        Severity: Minor
        Found in lib/grit/git-ruby/repository.rb - 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

        Class Repository has 42 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class Repository
        
              class NoSuchShaFound < StandardError
              end
        
        
        Severity: Minor
        Found in lib/grit/git-ruby/repository.rb - About 5 hrs to fix

          Method quick_diff has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
          Open

                def quick_diff(tree1, tree2, path = '.', recurse = true)
                  # handle empty trees
                  return changed if tree1 == tree2
          
                  t1 = list_tree(tree1) if tree1
          Severity: Minor
          Found in lib/grit/git-ruby/repository.rb - 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

          Method native has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

              def native(cmd, options = {}, *args, &block)
                args     = args.first if args.size == 1 && args[0].is_a?(Array)
                args.map!    { |a| a.to_s }
                args.reject! { |a| a.empty? }
          
          
          Severity: Minor
          Found in lib/grit/git.rb - 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

          Method tags has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              def tags(options, prefix)
                refs = []
                already = {}
          
                orig_prefix = prefix
          Severity: Minor
          Found in lib/grit/git-ruby.rb - 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

          Class Git has 28 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Git
              include POSIX::Spawn
          
              class GitTimeout < RuntimeError
                attr_accessor :command
          Severity: Minor
          Found in lib/grit/git.rb - About 3 hrs to fix

            Method advanced_grep has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

                def advanced_grep(searchtext, contextlines = 3, branch = 'master')
            
                  # If there's not an even number of quote marks, get rid of them all
                  searchtext = searchtext.gsub('"', '') if searchtext.count('"') % 2 == 1
            
            
            Severity: Minor
            Found in lib/grit/repo.rb - 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

            File git_object.rb has 281 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require 'stringio'
            
            module Grit
              module GitRuby
            
            
            Severity: Minor
            Found in lib/grit/git-ruby/git_object.rb - About 2 hrs to fix

              Method rev_parse has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  def rev_parse(options, string)
                    raise RuntimeError, "invalid string: #{string.inspect}" unless string.is_a?(String)
              
                    # Split ranges, but don't split when specifying a ref:path.
                    # Don't split HEAD:some/path/in/repo..txt
              Severity: Minor
              Found in lib/grit/git-ruby.rb - 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

              File git.rb has 271 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              require 'tempfile'
              require 'posix-spawn'
              module Grit
              
                class Git
              Severity: Minor
              Found in lib/grit/git.rb - About 2 hrs to fix

                Class Commit has 23 methods (exceeds 20 allowed). Consider refactoring.
                Open

                  class Commit
                    extend Lazy
                
                    attr_reader :id
                    attr_reader :repo
                Severity: Minor
                Found in lib/grit/commit.rb - About 2 hrs to fix

                  Method refs has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def refs(options, prefix)
                        refs = []
                        already = {}
                        orig_prefix = prefix
                        prefix = File.join @git_dir, prefix
                  Severity: Minor
                  Found in lib/grit/git-ruby.rb - 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

                  Method list_from_string has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def self.list_from_string(repo, text)
                        text_gpgless = text.gsub(/gpgsig -----BEGIN PGP SIGNATURE-----[\n\r](.*[\n\r])*? -----END PGP SIGNATURE-----[\n\r]/, "")
                        lines = text_gpgless.split("\n")
                  
                        commits = []
                  Severity: Minor
                  Found in lib/grit/commit.rb - 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

                  Method diff has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def diff(commit1, commit2, options = {})
                          patch = ''
                  
                          commit_obj1 = get_object_by_sha1(commit1)
                          tree1 = commit_obj1.tree
                  Severity: Major
                  Found in lib/grit/git-ruby/repository.rb - About 2 hrs to fix

                    Method advanced_grep has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def advanced_grep(searchtext, contextlines = 3, branch = 'master')
                    
                          # If there's not an even number of quote marks, get rid of them all
                          searchtext = searchtext.gsub('"', '') if searchtext.count('"') % 2 == 1
                    
                    
                    Severity: Major
                    Found in lib/grit/repo.rb - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language