Showing 269 of 269 total issues
Method export
has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring. Open
def export(zip_file_path, options = {})
begin
referential.switch
if referential_exportable? && options[:start_date] && options[:end_date]
FileUtils.rm(zip_file_path) if File.exists? zip_file_path
- 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
Class TimeTable
has 51 methods (exceeds 20 allowed). Consider refactoring. Open
class Chouette::TimeTable < Chouette::TridentActiveRecord
include TimeTableRestrictions
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
Similar blocks of code found in 2 locations. Consider refactoring. Open
$.datepicker.regional['fr'] = {
closeText: 'Fermer',
prevText: '<Préc',
nextText: 'Suiv>',
currentText: 'Courant',
- 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 145.
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
$.datepicker.regional['en'] = {
closeText: 'Done',
prevText: 'Prev',
nextText: 'Next',
currentText: 'Today',
- 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 145.
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
Class StopArea
has 40 methods (exceeds 20 allowed). Consider refactoring. Open
class Chouette::StopArea < Chouette::TridentActiveRecord
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
include Geokit::Mappable
include ProjectionFields
Class VehicleJourneyExport
has 40 methods (exceeds 20 allowed). Consider refactoring. Open
class VehicleJourneyExport
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
Method clean
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
def clean
# as foreign keys are presents , delete method can be used for faster performance
result = CleanUpResult.new
# find and remove time_tables
tms = Chouette::TimeTable.validity_out_from_on?(Date.parse(expected_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 mode_default_params
has 128 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.mode_default_params
{
:coach => {
:allowed_transport_mode_coach => false,
:inter_stop_area_distance_min_mode_coach => 500,
File time_table.rb
has 369 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Chouette::TimeTable < Chouette::TridentActiveRecord
include TimeTableRestrictions
# FIXME http://jira.codehaus.org/browse/JRUBY-6358
self.primary_key = "id"
Method creation_tag
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def creation_tag(object)
field_set_tag t("layouts.history_tag.title"), :class => "history_tag" do
content_tag :ul do
[(content_tag :li do
if object.has_attribute?(:creation_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 export
has 118 lines of code (exceeds 25 allowed). Consider refactoring. Open
def export(zip_file_path, options = {})
begin
referential.switch
if referential_exportable? && options[:start_date] && options[:end_date]
FileUtils.rm(zip_file_path) if File.exists? zip_file_path
Method merge!
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def merge!(another_tt)
transaction do
# if one tt has no period, just merge lists
if self.periods.empty? || another_tt.periods.empty?
if !another_tt.periods.empty?
- 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 customize_map
has 103 lines of code (exceeds 25 allowed). Consider refactoring. Open
def customize_map(map, page)
if stop_area.parents.present?
page.assign "parents_layer", kml_layer(stop_area, { :parents => true }, :style_map => Design::StopAreasStyleMap.new(helpers).style_map)
page << map.add_layer(:parents_layer)
page << map.add_control( hover_control_display_name(:parents_layer) )
Class Referential
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
class Referential < ActiveRecord::Base
include DataFormatEnumerations
validates_presence_of :name
validates_presence_of :prefix
File rule_parameter_set.rb
has 312 lines of code (exceeds 250 allowed). Consider refactoring. Open
class RuleParameterSet < ActiveRecord::Base
belongs_to :organisation
#validates_presence_of :referential
validates_presence_of :name
Method export
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def export(zip_file_path, options = {})
begin
referential.switch
FileUtils.rm(zip_file_path) if File.exists? zip_file_path
- 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
Class Client
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Client
include Ievkitdeprecated::Configurable
include Ievkitdeprecated::Authentication
include Ievkitdeprecated::Client::Jobs
Method clean
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
def clean
# as foreign keys are presents , delete method can be used for faster performance
result = CleanUpResult.new
# find and remove time_tables
tms = Chouette::TimeTable.validity_out_from_on?(Date.parse(expected_date))
Method load_imported_vehicle_journeys
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def load_imported_vehicle_journeys
spreadsheet = open_spreadsheet(file)
vehicle_journeys = []
- 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 execute_geometry
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def execute_geometry(secondary = false)
if secondary && Rails.application.secrets.osrm_secondary_endpoint.present?
@osrm_endpoint = Rails.application.secrets.osrm_secondary_endpoint
end
- 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"