Showing 103 of 103 total issues
Method calculate_before
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.calculate_before(current)
return first_text if current == first_text
alphabet = self.alphabet.split('')
return alphabet.first if current.blank?
- Read upRead up
- Create a ticketCreate a ticket
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 links
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def links(book)
response = []
response.push link_to 'WorldCat', "http://www.worldcat.org/isbn/#{ book.isbn_13 }" unless book.isbn_13.blank?
response.push link_to 'GoogleBooks', "http://books.google.com/books?id=#{ book.google_books_id }" unless book.google_books_id.blank?
response.push link_to 'LibraryThing', "http://www.librarything.com/work/#{ book.library_thing_id }" unless book.library_thing_id.blank?
- Read upRead up
- Create a ticketCreate a ticket
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 createMarker
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Gmaps4RailsMapquest.prototype.createMarker = function(args) {
var icon, marker;
marker = new MQA.Poi({
lat: args.Lat,
lng: args.Lng
- Create a ticketCreate a ticket
Method initialize
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(note, sequence)
versions = note.versions
if sequence == 1
version = versions.first.reify
- Create a ticketCreate a ticket
Function create_polygon
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Gmaps4Rails.prototype.create_polygon = function(polygon) {
var clickable, fillColor, fillOpacity, latlng, new_poly, point, polygon_coordinates, strokeColor, strokeOpacity, strokeWeight, _i, _len;
polygon_coordinates = [];
for (_i = 0, _len = polygon.length; _i < _len; _i++) {
point = polygon[_i];
- Create a ticketCreate a ticket
Method calculate_after
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.calculate_after(current)
return last_text if current == last_text
alphabet = self.alphabet.split('')
alphabet_without_space = alphabet - [' ']
- Create a ticketCreate a ticket
Method cut_image_binary
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def cut_image_binary(id, _format, aspect_x, aspect_y, width, snap, gravity, effects)
- Create a ticketCreate a ticket
Consider simplifying this complex logical expression. Open
if (point === polygon[0]) {
strokeColor = point.strokeColor || this.polygons_conf.strokeColor;
strokeOpacity = point.strokeOpacity || this.polygons_conf.strokeOpacity;
strokeWeight = point.strokeWeight || this.polygons_conf.strokeWeight;
fillColor = point.fillColor || this.polygons_conf.fillColor;
- Create a ticketCreate a ticket
Method merge
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def merge(new_values, overwrite = false, object = self)
new_values.each do |key, value|
value.strip! if value.is_a? String
# REVIEW
# We can have various strategies here
- Read upRead up
- Create a ticketCreate a ticket
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 dir_attr
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def dir_attr(language)
if language != I18n.locale.to_s
page_direction = NB.rtl_langs.split(/, ?| /).include?(I18n.locale.to_s) ? 'rtl' : 'ltr'
this_direction = NB.rtl_langs.split(/, ?| /).include?(language) ? 'rtl' : 'ltr'
this_direction if page_direction != this_direction
- Read upRead up
- Create a ticketCreate a ticket
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 collate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def collate(source_text, target_text, source_lang)
source_dom = Nokogiri::HTML(source_text)
source_paragraphs = source_dom.css('p')
target_dom = Nokogiri::HTML(target_text)
- Read upRead up
- Create a ticketCreate a ticket
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
if (args.marker_anchor !== null) {
style_mark.graphicXOffset = args.marker_anchor[0];
style_mark.graphicYOffset = args.marker_anchor[1];
}
- Read upRead up
- Create a ticketCreate a ticket
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 53.
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 (args.shadow_anchor !== null) {
style_mark.backgroundXOffset = args.shadow_anchor[0];
style_mark.backgroundYOffset = args.shadow_anchor[1];
}
- Read upRead up
- Create a ticketCreate a ticket
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 53.
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 larger_cut_image_location
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def larger_cut_image_location(aspect_x, aspect_y, width, snap, gravity, effects, total_columns)
- Create a ticketCreate a ticket
Method bodify_collate
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def bodify_collate(source_text, target_text, source_lang, books = [], books_citation_style = 'citation.book.inline_annotated_html', links_citation_style = 'citation.link.inline_annotated_html', annotated = true)
- Create a ticketCreate a ticket
Method add_task
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def self.add_task(isbn_candidate)
isbn_candidate.gsub!(/[^\dX]/, '')
book = where(isbn_10: isbn_candidate).first_or_create if isbn_candidate.length == 10
book = where(isbn_13: isbn_candidate).first_or_create if isbn_candidate.length == 13
if book && book.dirty?
- Read upRead up
- Create a ticketCreate a ticket
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 cut_location
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def cut_location(aspect_x, aspect_y, width, snap, gravity, effects = '')
- Create a ticketCreate a ticket
Consider simplifying this complex logical expression. Open
if (element === polyline[0]) {
strokeColor = element.strokeColor || this.polylines_conf.strokeColor;
strokeOpacity = element.strokeOpacity || this.polylines_conf.strokeOpacity;
strokeWeight = element.strokeWeight || this.polylines_conf.strokeWeight;
clickable = element.clickable || this.polylines_conf.clickable;
- Create a ticketCreate a ticket
Consider simplifying this complex logical expression. Open
if (element === polyline[0]) {
strokeColor = element.strokeColor || this.polylines_conf.strokeColor;
strokeOpacity = element.strokeOpacity || this.polylines_conf.strokeOpacity;
strokeWeight = element.strokeWeight || this.polylines_conf.strokeWeight;
clickable = element.clickable || this.polylines_conf.clickable;
- Create a ticketCreate a ticket
Method bodify
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def bodify(text, books = [], books_citation_style = 'citation.book.inline_annotated_html', links_citation_style = 'citation.link.inline_annotated_html', annotated = true)
- Create a ticketCreate a ticket