Showing 203 of 203 total issues
Method perform
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def perform
noterm_emails_sent = {}
forbidden_emails_sent = {}
reminders = EmailReminder.where(:send_on => Date.today.wday).order(:section_id)
count = reminders.size
Method programme_meetings
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def programme_meetings
require_osm_permission :read, :programme
headers = [
'ID',
Method get_fake_data
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_fake_data
events = []
attendance = {}
(1 + rand(3)).times do |i|
Method show
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
@record = nil
record_id = params[:record_id].to_i
@section.flexi_records.each do |record|
Method send_email
has 28 lines of code (exceeds 25 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
Method create
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@user = User.new(params[:user].permit(:name, :email_address, :password, :password_confirmation, :gdpr_consent))
@user.gdpr_consent ||= false
if @signup_code
Method health
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def health
data = Status.new.health
status = data[:healthy] ? :ok : :service_unavailable
respond_with(data) do |format|
format.cacti { render cacti: {healthy: data[:healthy] ? 1 : 0}, status: status }
- 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 get_balanced_statistics
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_balanced_statistics(data, type)
statistics = {}
[:number, :time].each do |num_or_time|
statistics[num_or_time] = {
- 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 show
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def show
@record = nil
record_id = params[:record_id].to_i
@section.flexi_records.each do |record|
- 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_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
Similar blocks of code found in 2 locations. Consider refactoring. Open
rescue Osm::Error::NoCurrentTerm => exception
Rails.logger.error "(#{reminder.id} for user #{reminder.user_id}) No current term for section #{reminder.section_id}."
noterm_emails_sent[reminder.user_id] ||= []
unless noterm_emails_sent[reminder.user_id].include?(reminder.section_id)
EmailReminderMailer.no_current_term(reminder, exception).deliver_now
- 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 50.
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
rescue Osm::Error::NoCurrentTerm => exception
Rails.logger.error "(#{list.id} for user #{list.user_id}) No current term for section #{list.section_id}."
noterm_emails_sent[list.user_id] ||= []
unless noterm_emails_sent[list.user_id].include?(list.section_id)
EmailListMailer.no_current_term(list, exception).deliver_now
- 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 50.
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
Method email_reminders_data
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def email_reminders_data
todays_data = Statistics.create_or_retrieve_for_date(Date.today)
by_day = [todays_data['email_reminders_by_day'], todays_data['email_reminder_shares_by_day']]
by_day_max = 0
Method get_list
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_list
emails = Array.new
no_emails = Array.new
section = Osm::Section.get(user.osm_api, section_id)
fail Osm::Forbidden if section.nil?
Method get_data
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_data
earliest = configuration[:the_last_n_weeks].weeks.ago.to_date
latest = Date.current
api = user.osm_api
Method search_results
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def search_results
if params[:selected].nil?
flash[:error] = 'You must select some fields to search.'
redirect_to osm_search_members_form_path(:search_for => params[:search_for]) and return
end
Identical blocks of code found in 2 locations. Consider refactoring. Open
def next_birthday_for_member(member, from=Date.current)
year = from.year
mmdd = member.date_of_birth.strftime('%m%d')
year += 1 if mmdd < from.strftime('%m%d')
mmdd = '0301' if mmdd == '0229' && !Date.parse("#{year}0101").leap?
- 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 46.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
def next_birthday_for_member(member, from=Date.current)
year = from.year
mmdd = member.date_of_birth.strftime('%m%d')
year += 1 if mmdd < from.strftime('%m%d')
mmdd = '0301' if mmdd == '0229' && !Date.parse("#{year}0101").leap?
- 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 46.
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
Method flexi_record
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def flexi_record
require_osm_permission :read, :flexi
flexi_record = nil
flexi_record_id = params[:flexi_record_id].to_i
- 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 gdpr_consent_given
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def gdpr_consent_given
if params[:gdpr_consent].eql?('1')
if current_user.update gdpr_consent_at: Time.now.utc
redirect_to session[:return_to].nil? ? my_page_path : session.delete(:return_to), :notice => 'Thank you, your consent has been recorded.'
else
- 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"