Showing 39 of 39 total issues
Complex method content#title (247.1) Open
content title: proc { t '.utilities' } do
tabs do
tab t('.cache_clear.title') do
para "Кеш можно сбрасывать не чаще, чем раз в #{ClearCache::TIME_THRESHOLD.in_minutes.ceil} минут."
table do
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method index#download_links (126.6) Open
index download_links: [:csv], title: -> { t '.title', date: l(@activity.date) } do
selectable_column
column :athlete
column(:role) { |v| human_volunteer_role v.role }
column :comment
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method Athlete#award_by_five_plus_badge? (40.5) Open
def award_by_five_plus_badge?
initial_date = Date.current.saturday? ? Date.current : Date.tomorrow.prev_week(:saturday)
Activity
.where(id: results.select(:activity_id))
.or(Activity.where(id: Volunteer.where(athlete: self).select(:activity_id)))
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method Users::ImageCompressor#call (40.3) Open
def call
return unless @user.image.attached?
return if Vips::Image.new_from_file(image_file.path).size.max <= MAX_DIMENSION && image_file.size <= MAX_SIZE
compressed_image_file = ImageProcessing::Vips
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method main#destroy (35.8) Open
def destroy
if resource.user_id
flash[:error] = t '.cannot_delete_registered'
elsif resource.results.exists? || Volunteer.exists?(athlete: resource)
flash[:error] = t '.cannot_delete_participant'
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Function handle_choice
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
handle_choice(event) {
const current_choice = this.resultsTarget.querySelector('li.active')
if (event.which == 40) {
const next_item = current_choice ? current_choice.nextElementSibling : this.resultsTarget.querySelector('li:first-child')
if (next_item) {
- 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
Complex method Parkzhrun::AthleteFinder#call (33.9) Open
def call
return unless @code
return @athlete if find_athlete_by_code
if find_athlete_by_info
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Similar blocks of code found in 2 locations. Consider refactoring. Open
connect() {
this.element.addEventListener("mouseenter", this.show.bind(this))
this.element.addEventListener("mouseleave", this.hide.bind(this))
}
- 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 64.
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
disconnect() {
this.element.removeEventListener("mouseenter", this.show.bind(this))
this.element.removeEventListener("mouseleave", this.hide.bind(this))
}
- 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 64.
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
Complex method UsersController#update (32.9) Open
def update
if current_user.update(user_params)
if params[:delete_image]
current_user.image.purge
elsif params[:user][:image] && current_user.image.attached?
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method AthletesController#index (32.3) Open
def index
query = params[:q].to_s.gsub(/[^[:alnum:][:blank:]]/, '').strip
criteria = Athlete.order(:event_id).limit(100)
@athletes =
if query.length < 3
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method FullProfileAwardingJob#award_athletes (31.5) Open
def award_athletes
athletes_dataset
.where.not(id: badge.trophies.select(:athlete_id))
.where.not(event_id: nil)
.distinct
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method TimerParser#process_table (29.0) Open
def process_table
column_correction = 1
Result.without_auditing do
table[1..].each do |row|
break if row.first == 'ENDOFEVENT'
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Method call
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def call
return unless @code
return @athlete if find_athlete_by_code
if find_athlete_by_info
- 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 process_table
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def process_table
column_correction = 1
Result.without_auditing do
table[1..].each do |row|
break if row.first == 'ENDOFEVENT'
- 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
Complex method AthletesController#show (27.8) Open
def show
@athlete = Athlete.find(params[:id])
results = @athlete.results.published
@total_results = results.size
if @total_results.positive?
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method FunrunAwardingJob#perform (27.6) Open
def perform(activity_id, badge_id)
activity = Activity.published.find activity_id
badge = Badge.find badge_id
return unless badge.funrun_kind? || badge.jubilee_participating_kind?
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method FivePlusAwardingJob#perform (27.5) Open
def perform(activity_id, with_expiration: false)
expire_trophies if with_expiration
activity = Activity.published.find activity_id
activity.participants.where.not(id: five_plus_badge.trophies.select(:athlete_id)).find_each do |athlete|
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Function sortTable
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
sortTable(table, column_idx, sort_direction) {
const result = Array.prototype.slice.call(table.querySelectorAll('tbody>tr')).sort((a, b) => {
const el1 = a.querySelector(`td:nth-child(${column_idx + 1})`)
const el2 = b.querySelector(`td:nth-child(${column_idx + 1})`)
let val1 = el1.getAttribute('sort_by') || el1.innerHTML
- 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
Complex method member_action#publish (26.1) Open
member_action :publish, method: :put do
if resource.results.empty?
flash[:error] = t '.empty_protocol'
elsif resource.correct?
resource.update!(published: true)
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool