gitlabhq/gitlabhq

View on GitHub
app/controllers/projects_controller.rb

Summary

Maintainability
D
1 day
Test Coverage

Class ProjectsController has 44 methods (exceeds 20 allowed). Consider refactoring.
Open

class ProjectsController < Projects::ApplicationController
  include API::Helpers::RelatedResourcesHelpers
  include IssuableCollections
  include ExtractsPath
  include PreviewMarkdown
Severity: Minor
Found in app/controllers/projects_controller.rb - About 6 hrs to fix

    File projects_controller.rb has 377 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class ProjectsController < Projects::ApplicationController
      include API::Helpers::RelatedResourcesHelpers
      include IssuableCollections
      include ExtractsPath
      include PreviewMarkdown
    Severity: Minor
    Found in app/controllers/projects_controller.rb - About 5 hrs to fix

      Method project_params_attributes has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def project_params_attributes
          [
            :avatar,
            :build_allow_git_fetch,
            :build_coverage_regex,
      Severity: Minor
      Found in app/controllers/projects_controller.rb - About 1 hr to fix

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

          def render_landing_page
            if can?(current_user, :download_code, @project)
              return render 'projects/no_repo' unless @project.repository_exists?
        
              render 'projects/empty' if @project.empty_repo?
        Severity: Minor
        Found in app/controllers/projects_controller.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 refs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def refs
            find_refs = params['find']
        
            find_branches = true
            find_tags = true
        Severity: Minor
        Found in app/controllers/projects_controller.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