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 21 (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

Method import_csv has 41 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 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Method mass_tag has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def mass_tag
          lookup_query
      
          if params[:tag] && (params[:tag] != "")
            if params[:table_name] == 'exact'
      Severity: Minor
      Found in app/controllers/admin_public_body_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 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

      Avoid deeply nested control flow statements.
      Open

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

        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]
              @query = nil 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