Method awarded_badges
has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring. Open
def awarded_badges
require_section_type Constants::YOUTH_SECTIONS
require_osm_permission(:read, :badge)
dates = [Osm.parse_date(@my_params[:start]), Osm.parse_date(@my_params[:finish])]
- 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 calendar
has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring. Open
def calendar
dates = [Osm.parse_date(@my_params[:start]), Osm.parse_date(@my_params[:finish])]
if dates.include?(nil)
flash[:error] = 'You failed to provide at least one of the dates.'
redirect_back_or_to reports_path
- 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
File reports_controller.rb
has 519 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ReportsController < ApplicationController
before_action :require_connected_to_osm
before_action { @my_params = (params[params[:action]] || {}) }
def index
Method planned_badge_requirements
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
def planned_badge_requirements
require_section_type Constants::YOUTH_SECTIONS
require_osm_permission(:read, :programme)
require_osm_permission(:read, :events) if current_section.subscription_at_least?(:silver)
Method awarded_badges
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
def awarded_badges
require_section_type Constants::YOUTH_SECTIONS
require_osm_permission(:read, :badge)
dates = [Osm.parse_date(@my_params[:start]), Osm.parse_date(@my_params[:finish])]
Method badge_completion_matrix
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
def badge_completion_matrix
require_section_type Constants::YOUTH_AND_ADULT_SECTIONS
require_osm_permission(:read, :badge)
return if performed? # The above either redirected or rendered
Consider simplifying this complex logical expression. Open
if PlannedBadgeRequirementsReport.data_for?(
current_user.id,
current_section.id,
start: dates.first,
finish: dates.last,
Method planned_badge_requirements
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def planned_badge_requirements
require_section_type Constants::YOUTH_SECTIONS
require_osm_permission(:read, :programme)
require_osm_permission(:read, :events) if current_section.subscription_at_least?(:silver)
- 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 event_attendance
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
def event_attendance
require_section_type Constants::YOUTH_AND_ADULT_SECTIONS
require_osm_permission(:read, :events)
return if performed? # The above either redirected or rendered
Method calendar
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def calendar
dates = [Osm.parse_date(@my_params[:start]), Osm.parse_date(@my_params[:finish])]
if dates.include?(nil)
flash[:error] = 'You failed to provide at least one of the dates.'
redirect_back_or_to reports_path
Method missing_badge_requirements
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def missing_badge_requirements
require_section_type Constants::YOUTH_SECTIONS
require_osm_permission(:read, :badge)
return if performed? # The above either redirected or rendered
Method index
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def index
@sections = Osm::Section.get_all(osm_api)
if has_osm_permission?(:read, :member)
@groupings = get_current_section_groupings.sort do |a,b|
- 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 leader_access_audit
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def leader_access_audit
unless @my_params[:sections].is_a?(Hash)
flash[:error] = 'You must select some sections to sudit'
redirect_to reports_path
return
Method event_attendance
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def event_attendance
require_section_type Constants::YOUTH_AND_ADULT_SECTIONS
require_osm_permission(:read, :events)
return if performed? # The above either redirected or rendered
- 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 badge_stock_check
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def badge_stock_check
@my_params = params.require(:badge_stock_check)
.permit(:include_core, :include_activity, :include_challenge, :include_staged, :hide_no_stock)
require_section_type Constants::YOUTH_AND_ADULT_SECTIONS
Method badge_completion_matrix
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def badge_completion_matrix
require_section_type Constants::YOUTH_AND_ADULT_SECTIONS
require_osm_permission(:read, :badge)
return if performed? # The above either redirected or rendered
- 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 missing_badge_requirements
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def missing_badge_requirements
require_section_type Constants::YOUTH_SECTIONS
require_osm_permission(:read, :badge)
return if performed? # The above either redirected or rendered
- 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
Consider simplifying this complex logical expression. Open
if params[:waiting]
if PlannedBadgeRequirementsReport.data_for?(
current_user.id,
current_section.id,
start: dates.first,