gitlabhq/grit

View on GitHub
lib/grit/git.rb

Summary

Maintainability
D
1 day
Test Coverage

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

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

    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

      Method native has 35 lines of code (exceeds 25 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 1 hr to fix

        Method options_to_argv has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def options_to_argv(options)
              argv = []
              options.each do |key, val|
                if key.to_s.size == 1
                  if val == true
        Severity: Minor
        Found in lib/grit/git.rb - 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

        Method transform_options has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def transform_options(options)
              args = []
              options.keys.each do |opt|
                if opt.to_s.size == 1
                  if options[opt] == true
        Severity: Minor
        Found in lib/grit/git.rb - 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

        Method initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def initialize(command, exitstatus=nil, err='', out='')
                if exitstatus
                  @command = command
                  @exitstatus = exitstatus
                  @err = err
        Severity: Minor
        Found in lib/grit/git.rb - 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

        There are no issues that match your filters.

        Category
        Status