gitlabhq/grack

View on GitHub

Showing 6 of 6 total issues

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

  class Server
    attr_reader :git

    SERVICES = [
      ["POST", 'service_rpc',      "(.*?)/git-upload-pack$",  'upload-pack'],
Severity: Minor
Found in lib/grack/server.rb - About 3 hrs to fix

    Method has_access? has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def has_access?(rpc, check_content_type = false)
          if check_content_type
            conten_type = "application/x-git-%s-request" % rpc
            return false unless @req.content_type == conten_type
          end
    Severity: Minor
    Found in lib/grack/server.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 send_file has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def send_file(reqfile, content_type)
          reqfile = File.join(git.repo, reqfile)
          return render_not_found unless File.exists?(reqfile)
    
          return render_not_found unless reqfile == File.realpath(reqfile)
    Severity: Minor
    Found in lib/grack/server.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 call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def call(env)
          @env = env
          @request = Rack::Request.new(env)
          @auth = Request.new(env)
    
    
    Severity: Minor
    Found in lib/grack/auth.rb - 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

    Method match_routing has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def match_routing
          cmd = nil
          path = nil
    
          SERVICES.each do |method, handler, match, rpc|
    Severity: Minor
    Found in lib/grack/server.rb - 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

    Method valid_repo? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def valid_repo?
          return false unless File.exists?(repo) && File.realpath(repo) == repo
    
          match = execute(%W(rev-parse --git-dir)).match(/\.$|\.git$/)
          
    Severity: Minor
    Found in lib/grack/git.rb - 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

    Severity
    Category
    Status
    Source
    Language