mysociety/alaveteli

View on GitHub
app/controllers/admin_public_body_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

Method import_csv has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def import_csv
    @notes = ""
    @errors = ""
    if request.post?
      dry_run_only = params['commit'] != 'Upload'
Severity: Minor
Found in app/controllers/admin_public_body_controller.rb - About 2 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

File admin_public_body_controller.rb has 256 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class AdminPublicBodyController < AdminController

  include TranslatableParams

  before_filter :set_public_body, :only => [:edit, :update, :destroy]
Severity: Minor
Found in app/controllers/admin_public_body_controller.rb - About 2 hrs to fix

    Method import_csv has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def import_csv
        @notes = ""
        @errors = ""
        if request.post?
          dry_run_only = params['commit'] != 'Upload'
    Severity: Minor
    Found in app/controllers/admin_public_body_controller.rb - About 1 hr to fix

      Method lookup_query has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def lookup_query
          @locale = AlaveteliLocalization.locale
          AlaveteliLocalization.with_locale(@locale) do
            @query = params[:query]
            if @query == ""
      Severity: Minor
      Found in app/controllers/admin_public_body_controller.rb - About 1 hr to fix

        Method mass_tag_add has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def mass_tag_add
            lookup_query
        
            if params[:new_tag] and params[:new_tag] != ""
              if params[:table_name] == 'exact'
        Severity: Minor
        Found in app/controllers/admin_public_body_controller.rb - About 45 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

        Avoid deeply nested control flow statements.
        Open

                    if errors.size != 0
                      raise "dry run mismatched real run"
                    end
        Severity: Major
        Found in app/controllers/admin_public_body_controller.rb - About 45 mins to fix

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

            def create
              AlaveteliLocalization.with_locale(AlaveteliLocalization.default_locale) do
                if params[:change_request_id]
                  @change_request = PublicBodyChangeRequest.find(params[:change_request_id])
                end
          Severity: Minor
          Found in app/controllers/admin_public_body_controller.rb - About 45 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 lookup_query has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def lookup_query
              @locale = AlaveteliLocalization.locale
              AlaveteliLocalization.with_locale(@locale) do
                @query = params[:query]
                if @query == ""
          Severity: Minor
          Found in app/controllers/admin_public_body_controller.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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def update
              if params[:change_request_id]
                @change_request = PublicBodyChangeRequest.find(params[:change_request_id])
              end
              AlaveteliLocalization.with_locale(AlaveteliLocalization.default_locale) do
          Severity: Minor
          Found in app/controllers/admin_public_body_controller.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

          There are no issues that match your filters.

          Category
          Status