gitlabhq/gitlabhq

View on GitHub
lib/api/helpers.rb

Summary

Maintainability
C
7 hrs
Test Coverage

File helpers.rb has 386 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module API
  module Helpers
    include Gitlab::Utils
    include Helpers::Pagination

Severity: Minor
Found in lib/api/helpers.rb - About 5 hrs to fix

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

        def sudo!
          return unless sudo_identifier
    
          unauthorized! unless initial_current_user
    
    
    Severity: Minor
    Found in lib/api/helpers.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 project_finder_params has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def project_finder_params
          finder_params = { without_deleted: true }
          finder_params[:owned] = true if params[:owned].present?
          finder_params[:non_public] = true if params[:membership].present?
          finder_params[:starred] = true if params[:starred].present?
    Severity: Minor
    Found in lib/api/helpers.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 present_carrierwave_file! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def present_carrierwave_file!(file, supports_direct_download: true)
          return not_found! unless file&.exists?
    
          if file.file_storage?
            present_disk_file!(file.path, file.filename)
    Severity: Minor
    Found in lib/api/helpers.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