Showing 242 of 242 total issues
Function buildStartEndsWith
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function buildStartEndsWith() {
var override = true;
try {
// If String#startsWith does not exist or alternately if it exists but
// correctly throws an error here, then there is no need to flag the
Method transition_actions
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def transition_actions(*actions)
actions = actions.first.is_a?(Symbol) ? actions : actions.first
actions.each do |action|
define_method action do
- 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 create
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def create
build_resource(params[:user])
captcha_verified = if Rails.env == 'production'
verify_recaptcha(model: resource, message: I18n.t('general.exceptions.wrong_recaptcha'))
- 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 path_to
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def path_to(page_name)
case page_name
when /^the home\s?page$/
'/'
Function letWinnerWinMatchesAgainstCompetitorsWhichLoseAgainstLoser
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
CompetitiveList.prototype.letWinnerWinMatchesAgainstCompetitorsWhichLoseAgainstLoser = function(winnerId, loserId) {
var base;
(base = this.defeatedCompetitorsByCompetitor)[loserId] || (base[loserId] = []);
return $.each(this.matches, (function(_this) {
return function(index, match) {
Method down
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def down
unless (Product::Recruiting rescue nil)
create_table 'vacancies', force: true do |t|
t.string 'type'
t.integer 'project_id'
Method update
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
if params[:event] && params[:event].keys.select{|k| ['cancel', 'skip'].include?(k)}.any?
send(params[:event].keys.first)
return
end
Method gem_dependencies
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def gem_dependencies
add_source "http://gems.github.com"
# core
gem 'rack-cors', '~> 0.2.4', require: 'rack/cors'
Method wizard_steps
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def wizard_steps(*wizard_steps)
const_set 'WIZARD_STEPS', wizard_steps
# TODO: clarify if we still need to generate actions when we have an update action and next_step trigger
"::#{self.to_s}::WIZARD_STEPS".constantize.each do |wizard_step|
- 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 eager_load_polymorphs
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def eager_load_polymorphs(list, includes)
polymorphs = {}
logger.debug "eager_load_polymorphs for list length: #{list.length}"
- 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 find_or_create_by_params
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.find_or_create_by_params(params)
attributes = (params[:user_list_item] || params[:list_item] || params).clone
attributes.symbolize_keys! unless params.is_a?(ActiveSupport::HashWithIndifferentAccess)
if attributes[:list_id].present? then List.find(attributes[:list_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
Function sortByMostWins
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
CompetitiveList.prototype.sortByMostWins = function(after_update_request_proc) {
var $wrapper, data, positions, winsByCompetitor;
if (after_update_request_proc == null) {
after_update_request_proc = null;
}
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (match['winner'] !== void 0) {
_this.removeCompetitorsComparisonResult(winnerId, otherLoserId);
if (!(_this.movingCompetitorToPosition === true || match['auto_winner'] === true)) {
manual_winner_changed = true;
}
- 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 65.
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
if (match['winner'] !== void 0) {
_this.removeCompetitorsComparisonResult(competitorId, loserId);
if (!(_this.movingCompetitorToPosition === true || match['auto_winner'] === true)) {
manual_winner_changed = true;
}
- 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 65.
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 3 locations. Consider refactoring. Open
Then /^(an|no) email should have been sent((?: |and|with|from "[^"]+"|to "[^"]+"|the subject "[^"]+"|the body "[^"]+"|the attachments "[^"]+")+)$/ do |mode, query|
conditions = {}
conditions[:to] = $1 if query =~ /to "([^"]+)"/
conditions[:from] = $1 if query =~ /from "([^"]+)"/
conditions[:subject] = $1 if query =~ /the subject "([^"]+)"/
- 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 62.
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 3 locations. Consider refactoring. Open
Then /^(an|no) email should have been sent((?: |and|with|from "[^"]+"|to "[^"]+"|the subject "[^"]+"|the body "[^"]+"|the attachments "[^"]+")+)$/ do |mode, query|
conditions = {}
conditions[:to] = $1 if query =~ /to "([^"]+)"/
conditions[:from] = $1 if query =~ /from "([^"]+)"/
conditions[:subject] = $1 if query =~ /the subject "([^"]+)"/
- 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 62.
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 3 locations. Consider refactoring. Open
Then /^(an|no) email should have been sent((?: |and|with|from "[^"]+"|to "[^"]+"|the subject "[^"]+"|the body "[^"]+"|the attachments "[^"]+")+)$/ do |mode, query|
conditions = {}
conditions[:to] = $1 if query =~ /to "([^"]+)"/
conditions[:from] = $1 if query =~ /from "([^"]+)"/
conditions[:subject] = $1 if query =~ /the subject "([^"]+)"/
- 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 62.
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 create_from_table
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_from_table(model_name, table, extra = {})
factory_name = model_name.gsub(/\W+/, '_').downcase.singularize.to_sym
is_singular = model_name.to_s.singularize == model_name.to_s
hashes = if is_singular
Method path_to
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def path_to(page_name)
case page_name
when /^the home\s?page$/
'/'
Method create_from_table
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_from_table(model_name, table, extra = {})
factory_name = model_name.gsub(/\W+/, '_').downcase.singularize.to_sym
is_singular = model_name.to_s.singularize == model_name.to_s
hashes = if is_singular