opengovernment/askthem

View on GitHub
app/controllers/pages_controller.rb

Summary

Maintainability
D
1 day
Test Coverage

Class PagesController has 41 methods (exceeds 20 allowed). Consider refactoring.
Open

class PagesController < ApplicationController
  DEFAULT_GEOJSON_CENTER = [-73.9998334, 40.7195898]
  DEFAULT_MUNICIPALITY = "New York"

  skip_before_filter :verify_authenticity_token, :only => [:locator, :identifier]
Severity: Minor
Found in app/controllers/pages_controller.rb - About 5 hrs to fix

    File pages_controller.rb has 339 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class PagesController < ApplicationController
      DEFAULT_GEOJSON_CENTER = [-73.9998334, 40.7195898]
      DEFAULT_MUNICIPALITY = "New York"
    
      skip_before_filter :verify_authenticity_token, :only => [:locator, :identifier]
    Severity: Minor
    Found in app/controllers/pages_controller.rb - About 4 hrs to fix

      Method tab has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def tab(tab)
          @governor = Governor.connected_to(@jurisdiction.abbreviation).active.first
          @mayor = Mayor.connected_to(@jurisdiction.abbreviation).active.first ||
            Councilmember.connected_to(@jurisdiction.abbreviation).active
            .where(district: "Mayor").first
      Severity: Minor
      Found in app/controllers/pages_controller.rb - About 1 hr to fix

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

          def set_candidates_if_referring_partner
            return unless @has_partner
        
            extra_state_candidates = []
            people_collections.each do |name, ids|
        Severity: Minor
        Found in app/controllers/pages_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 tab has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

          def tab(tab)
            @governor = Governor.connected_to(@jurisdiction.abbreviation).active.first
            @mayor = Mayor.connected_to(@jurisdiction.abbreviation).active.first ||
              Councilmember.connected_to(@jurisdiction.abbreviation).active
              .where(district: "Mayor").first
        Severity: Minor
        Found in app/controllers/pages_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

        There are no issues that match your filters.

        Category
        Status