joegattnet/joegattnet_v3

View on GitHub

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?

Severity: Minor
Found in app/models/pantograph.rb - About 1 hr to fix

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?
Severity: Minor
Found in app/helpers/books_helper.rb - About 1 hr to fix

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
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.mapquest.js - About 1 hr to fix

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
Severity: Minor
Found in app/models/diffed_note_version.rb - About 1 hr to fix

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];
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.base.js - About 1 hr to fix

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 - [' ']

Severity: Minor
Found in app/models/pantograph.rb - About 1 hr to fix

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)
Severity: Major
Found in app/helpers/resources_helper.rb - About 1 hr to fix

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;
Severity: Major
Found in public/javascripts/gmaps4rails/gmaps4rails.base.js - About 1 hr to fix

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
Severity: Minor
Found in app/models/concerns/syncable.rb - About 55 mins to fix

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
Severity: Minor
Found in app/helpers/application_helper.rb - About 55 mins to fix

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)
Severity: Minor
Found in app/helpers/formatting_helper.rb - About 55 mins to fix

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];
        }
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.openlayers.js and 1 other location - About 55 mins to fix
public/javascripts/gmaps4rails/gmaps4rails.openlayers.js on lines 76..79

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

Further Reading

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];
          }
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.openlayers.js and 1 other location - About 55 mins to fix
public/javascripts/gmaps4rails/gmaps4rails.openlayers.js on lines 68..71

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

Further Reading

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)
Severity: Major
Found in app/models/resource.rb - About 50 mins to fix

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)
Severity: Major
Found in app/helpers/formatting_helper.rb - About 50 mins to fix

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?
Severity: Minor
Found in app/models/book.rb - About 45 mins to fix

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 = '')
Severity: Minor
Found in app/models/resource.rb - About 45 mins to fix

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;
Severity: Major
Found in public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js - About 40 mins to fix

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;
Severity: Major
Found in public/javascripts/gmaps4rails/gmaps4rails.openlayers.js - About 40 mins to fix

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)
Severity: Minor
Found in app/helpers/formatting_helper.rb - About 35 mins to fix
Severity
Category
Status
Source
Language