Showing 203 of 203 total issues
Method send_email
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def send_email(options={})
# :only_to is an array of strings or objects with an :email_address method or nil (send to everyone).
# :except_to is an array of strings or objects with an :email_address method or nil (send to everyone).
# :skip_subscribed_check if true then the email will be sent even if the subscription state is not :subscribed
- 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 sections
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def self.sections
section_ids_seen = []
section_types = {:beavers=>0, :cubs=>0, :scouts=>0, :explorers=>0, :adults=>0, :waiting=>0}
subscription_levels = {1=>0, 2=>0, 3=>0}
addons = {'Badges'=>0, 'Events'=>0, 'Payments'=>0, 'Programme'=>0, 'GoCardless'=>0}
- 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 perform_task
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform_task(user=self.user)
ret_val = {log_lines: log_lines=[], errors: errors=[]}
section = Osm::Section.get(user.osm_api, section_id)
if section.nil?
Method get_data
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def get_data
latest = configuration[:the_next_n_weeks].weeks.from_now.to_date
earliest = Date.current
api = user.osm_api
- 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 a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def self.badge_stock_check(user, section, options)
Rails.cache.fetch("user#{user.id}-report-badge_stock_check-data-#{options.inspect}", :expires_in => 10.minutes) do
badges = []
badges += Osm::CoreBadge.get_badges_for_section(user.osm_api, section) if options[:include_core]
- 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 fetch_data
has 84 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fetch_data(user_id, section_id, include_core:, include_challenge:, include_staged:, include_activity:, exclude_not_started:, exclude_all_finished:)
user = User.find(user_id)
osm_api = user.osm_api
section = Osm::Section.get(osm_api, section_id)
Method initialize
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
alias_action :destroy, :to=>:delete
alias_action :create, :read, :update, :delete, :to=>:administer
# Things everyone can do
- 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 create
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def create
user = login(params[:email_address].downcase, params[:password])
Rails.logger.debug "SessionsController#create: user is #{user.inspect}"
if user
- 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 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)
Function drawCharts
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
function drawCharts() {
$.ajax({
url: 'sections.json',
dataType:"json",
async: false,
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 members
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def members
require_osm_permission :read, :member
members = Osm::Member.get_for_section(osm_api, current_section, params[:term_id])
- 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 perform_task
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform_task(user=self.user)
ret_val = {log_lines: [], errors: []}
earliest = configuration[:the_last_n_days].days.ago.to_date
latest = configuration[:the_next_n_days].days.from_now.to_date
birthdays = []
Function drawCharts
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
function drawCharts() {
updateStatus('Retreiving data.');
$.ajax({
url: 'balanced_data',
Similar blocks of code found in 2 locations. Consider refactoring. Open
function changeColumnWidth(field, by) {
$('.cell_' + field).css('width', parseInt($('.cell_' + field).css('width')) + by);
$('#table').css('width', parseInt($('#table').css('width')) + by);
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 90.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
function changeColumnWidth(field, by) {
$('.field_' + field).css('width', parseInt($('.field_' + field).css('width')) + by);
$('#table').css('width', parseInt($('#table').css('width')) + by);
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 90.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
File osm_exports_controller.rb
has 281 lines of code (exceeds 250 allowed). Consider refactoring. Open
class OsmExportsController < ApplicationController
before_action :require_connected_to_osm
before_action {
params[:file_options] ||= {}
Method fetch_data
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fetch_data(user_id, section_id, include_core:, include_activity:, include_challenge:, include_staged:)
user = User.find(user_id)
osm_api = user.osm_api
section = Osm::Section.get(osm_api, section_id)
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
function setTextSize(to) {
$('.field_head').css('font-size', to);
$('.field_data').css('font-size', to);
$('.field_total').css('font-size', to);
$('.field_count').css('font-size', to);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 89.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76