Showing 922 of 922 total issues
Similar blocks of code found in 5 locations. Consider refactoring. Open
Navigate.propTypes = {
journeyPatterns: PropTypes.array.isRequired,
status: PropTypes.object.isRequired,
pagination: PropTypes.object.isRequired,
dispatch: PropTypes.func.isRequired
- 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 5 locations. Consider refactoring. Open
PeriodsInDay.propTypes = {
value: PropTypes.array.isRequired,
currentDate: PropTypes.object.isRequired,
index: PropTypes.number.isRequired,
onDeletePeriod: PropTypes.func.isRequired
- 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
Method find_stop_parent_or_create_message
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def find_stop_parent_or_create_message(stop_area_name, parent_station, resource)
parent = stop_areas.find_by(registration_number: parent_station)
unless parent
parent = stop_area_referential.stop_areas.find_by(registration_number: parent_station)
Method flattened_circulation_periods
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def flattened_circulation_periods
periods = time_tables.map(&:periods).flatten
out = []
dates = periods.map {|p| [p.period_start, p.period_end + 1.day]}
Method company_params
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def company_params
return @company_params if @company_params
fields = [
:objectid,
Method build_instance
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_instance(context, options = {})
options = { parent: nil, save: false }.update(options)
parent = options[:parent]
save = options[:save]
Function Navigate
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export default function Navigate({ dispatch, vehicleJourneys, pagination, status, filters}) {
let firstPage = 1
let lastPage = Math.ceil(pagination.totalCount / pagination.perPage)
let minVJ = (pagination.page - 1) * pagination.perPage + 1
if (pagination.totalCount == 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
Function timetable
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export default function timetable(state = {}, action) {
let newState, newPeriods, newDates, newCM
switch (action.type) {
case 'RECEIVE_TIME_TABLES':
let fetchedState = assign({}, state, {
- 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 extract_zip
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.extract_zip(source_file, target_directory)
Dir.chdir(target_directory) do
Zip::File.open(source_file) do |file|
files = 0
file.each do |entry|
- 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 build_object_from_nokogiri_element
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def build_object_from_nokogiri_element(element)
out = { _node: element }
element.elements.each do |child|
key = child.name.underscore.to_sym
- 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!
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def import!
netex_source.routing_constraint_zones.each do |zone|
decorator = Decorator.new(zone, line_provider: line_provider,
stop_area_provider: stop_area_provider,
code_space: code_space,
- 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 data
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def data(val=nil, &block)
if val || block_given?
@options[:data] ||= {}
if block_given? || val.is_a?(Proc)
@options[:data] = block || val
- 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 checksum_attributes
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def checksum_attributes(db_lookup = true)
[].tap do |attrs|
attrs << self.published_journey_name
attrs << self.published_journey_identifier
loaded_company = association(:company).loaded? ? company : company_light
- 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 update_codes
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def update_codes(model, resource, event)
return unless model.respond_to?(:codes) && resource.respond_to?(:codes_attributes)
resource.codes_attributes.each do |code_attributes|
short_name = code_attributes[:short_name]
- 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 componentDidUpdate
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
componentDidUpdate(prevProps, prevState) {
if(this.props.status.isFetching == false){
$('.table-2entries').each(function() {
var refH = []
var refCol = []
Function componentDidUpdate
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
componentDidUpdate(prevProps, prevState) {
if(this.props.status.isFetching == false){
// Don't forget the .modal pre selector to avoid modifying the DOM outside our modal
$('.modal .table-2entries').each(function() {
var refH = []
Function initSortables
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
initSortables() {
this.container.find(".source-referentials li").draggable({
connectToSortable: ".target",
placeholder: "placeholder",
revert: "invalid",
Function constructor
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(container_selector, formInput){
this.formInput = $(formInput);
this.container = $(container_selector);
this.searchInput = this.container.find('.search');
this.loader = this.container.find('.loader');
Method merge!
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def merge!
Rails.logger.info "Start Merge##{id} merge for #{referential_ids}"
CustomFieldsSupport.within_workgroup(workgroup) do
Chouette::Benchmark.measure('merge', merge: id) do
Method show
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def show
@custom_fields = Chouette::JourneyPattern.custom_fields_definitions(referential.workgroup)
respond_to do |format|
format.json do