Showing 922 of 922 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
else{
if (action.isShown){
newModalProps.vehicleJourney.footnotes.push(action.footnote)
}else{
newModalProps.vehicleJourney.footnotes = newModalProps.vehicleJourney.footnotes.filter((f) => {return f.id != action.footnote.id })
- 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 97.
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 build_instance
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def build_instance(context, options = {})
options = { parent: nil, save: false }.update(options)
parent = options[:parent]
save = options[:save]
- 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
Function render
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const {
vjas,
x,
y,
Method candidate_target_attributes
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
def candidate_target_attributes # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
Chouette::ModelAttribute.collection do # rubocop:disable Metrics/BlockLength
# Chouette::Line
select Chouette::Line, :name
select Chouette::Line, :color
Method import_stops
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import_stops
sorted_stops = source.stops.sort_by { |s| s.parent_station.present? ? 1 : 0 }
@stop_areas_id_by_registration_number = {}
CustomFieldsSupport.within_workgroup(workbench.workgroup) do
Method new_alt_calendar
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new_alt_calendar(options = {}, &block)
raise(ArgumentError, "No year given") unless options.has_key?(:year)
raise(ArgumentError, "No month given") unless options.has_key?(:month)
block ||= Proc.new {|d| nil}
Function render
has 76 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
let id = _.get(actions.getSelected(this.props.vehicleJourneys), ['0', 'short_id'])
if(this.props.status.isFetching == true) {
return false
File table_builder_helper.rb
has 293 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'table_builder_helper/column'
require 'table_builder_helper/url'
# table_builder_2
# A Rails helper that constructs an HTML table from a collection of objects. It
Class Line
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class Line < Chouette::ActiveRecord
before_validation :update_unpermitted_blank_values
has_metadata
include LineReferentialSupport
Class TimeOfDay
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class TimeOfDay
include Comparable
attr_reader :hour, :minute, :second, :day_offset, :utc_offset, :second_offset
alias min minute
File experimental.rb
has 291 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Merge::Referential
module Sanitizer
def sanitize_joins(query)
# in fact, new.slug is already sanitized but .. it is better to be safe than sorry.
Method thead
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
def thead(collection, columns, sortable, selectable, has_links, overhead, model, action)
content_tag :thead do
# Inserts overhead content if any specified
over_head = ''
Function vehicleJourney
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
const vehicleJourney= (state = {}, action, keep) => {
switch (action.type) {
case 'SELECT_VEHICLEJOURNEY':
return _.assign({}, state, {selected: !state.selected})
case 'CANCEL_SELECTION':
- 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 handle_serialize_option
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def handle_serialize_option attribute_name, opts
serializer = opts[:serialize]
define_method attribute_name do
return nil unless respond_to?(:options)
- 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 valid_days
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def self.valid_days(int_day_types)
# Build an array with day of calendar week (1-7, Monday is 1).
[].tap do |valid_days|
valid_days << 1 if day_by_mask(int_day_types,MONDAY)
valid_days << 2 if day_by_mask(int_day_types,TUESDAY)
- 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 import_transfers
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def import_transfers
@trips = {}
create_resource(:transfers).each(source.transfers, slice: 100, transaction: true) do |transfer, resource|
next unless transfer.type == '2'
from_id = @stop_areas_id_by_registration_number[transfer.from_stop_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 remove_periods!
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def remove_periods!(removed_periods)
deleted_dates = []
dates.each do |date|
if removed_periods.any? { |p| p.include? date.date }
deleted_dates << date
- 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
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def self.fetch key, opts={}
key = key.to_s
unless keys.include?(key)
logger.warn("Fetching unexpected ENV key `#{key}`")
keys << key
- 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
class Batch
def address(position, key: nil)
item = Item.new(position)
# Reuse an already defined Item
- 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 104.
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
class Batch
def shape(points, key: nil)
item = Item.new(points)
# Reuse an already defined Item
- 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 104.
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