app/controllers/pages_controller.rb
Class PagesController
has 41 methods (exceeds 20 allowed). Consider refactoring. Open
Open
class PagesController < ApplicationController
DEFAULT_GEOJSON_CENTER = [-73.9998334, 40.7195898]
DEFAULT_MUNICIPALITY = "New York"
skip_before_filter :verify_authenticity_token, :only => [:locator, :identifier]
File pages_controller.rb
has 339 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
class PagesController < ApplicationController
DEFAULT_GEOJSON_CENTER = [-73.9998334, 40.7195898]
DEFAULT_MUNICIPALITY = "New York"
skip_before_filter :verify_authenticity_token, :only => [:locator, :identifier]
Method tab
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Method set_candidates_if_referring_partner
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
def set_candidates_if_referring_partner
return unless @has_partner
extra_state_candidates = []
people_collections.each do |name, ids|
- Read upRead up
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
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
- Read upRead up
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"