mysociety/alaveteli

View on GitHub
app/controllers/public_body_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

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 list has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def list
        long_cache
    
        @tag = params[:tag] || 'all'
        @tag = Unicode.upcase(@tag) if @tag.scan(/./mu).size == 1
    Severity: Minor
    Found in app/controllers/public_body_controller.rb - About 1 hr to fix

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

        def list
          long_cache
      
          @tag = params[:tag] || 'all'
          @tag = Unicode.upcase(@tag) if @tag.scan(/./mu).size == 1
      Severity: Minor
      Found in app/controllers/public_body_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 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