mysociety/alaveteli

View on GitHub
app/controllers/public_body_controller.rb

Summary

Maintainability
D
1 day
Test Coverage

Method list has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

  def list
    long_cache
    # TODO: move some of these tag SQL queries into has_tag_string.rb

    like_query = params[:public_body_query]
Severity: Minor
Found in app/controllers/public_body_controller.rb - About 5 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 list has 114 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def list
    long_cache
    # TODO: move some of these tag SQL queries into has_tag_string.rb

    like_query = params[:public_body_query]
Severity: Major
Found in app/controllers/public_body_controller.rb - About 4 hrs to fix

    Method show has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

      def show
        long_cache
        @page = get_search_page_from_params
        requests_per_page = 25
    
    
    Severity: Minor
    Found in app/controllers/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 show has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def show
        long_cache
        @page = get_search_page_from_params
        requests_per_page = 25
    
    
    Severity: Major
    Found in app/controllers/public_body_controller.rb - About 2 hrs to fix

      Method view_email has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def view_email
          @public_body = PublicBody.find_by_url_name_with_historic(params[:url_name])
          raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil?
      
          AlaveteliLocalization.with_locale(AlaveteliLocalization.locale) do
      Severity: Minor
      Found in app/controllers/public_body_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