redmine/redmine

View on GitHub
app/controllers/projects_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

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

class ProjectsController < ApplicationController
  menu_item :overview
  menu_item :settings, :only => :settings
  menu_item :projects, :only => [:index, :new, :copy, :create]

Severity: Minor
Found in app/controllers/projects_controller.rb - About 2 hrs to fix

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

      def copy
        @issue_custom_fields = IssueCustomField.sorted.to_a
        @trackers = Tracker.sorted.to_a
        @source_project = Project.find(params[:id])
        if request.get?
    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 create has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def create
        @issue_custom_fields = IssueCustomField.sorted.to_a
        @trackers = Tracker.sorted.to_a
        @project = Project.new
        @project.safe_attributes = params[:project]
    Severity: Minor
    Found in app/controllers/projects_controller.rb - About 1 hr to fix

      Method index has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def index
          # try to redirect to the requested menu item
          if params[:jump] && redirect_to_menu_item(params[:jump])
            return
          end
      Severity: Minor
      Found in app/controllers/projects_controller.rb - About 1 hr to fix

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

          def create
            @issue_custom_fields = IssueCustomField.sorted.to_a
            @trackers = Tracker.sorted.to_a
            @project = Project.new
            @project.safe_attributes = params[:project]
        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 destroy has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def destroy
            unless @project.deletable?
              deny_access
              return
            end
        Severity: Minor
        Found in app/controllers/projects_controller.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 archive has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def archive
            unless @project.archive
              error = l(:error_can_not_archive_project)
            end
            respond_to do |format|
        Severity: Minor
        Found in app/controllers/projects_controller.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 index has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def index
            # try to redirect to the requested menu item
            if params[:jump] && redirect_to_menu_item(params[:jump])
              return
            end
        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