joegattnet/joegattnet_v3

View on GitHub

Showing 65 of 103 total issues

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 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 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 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.openlayers.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.googlemaps.js - About 40 mins to fix

Function createMarkerImage has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    Gmaps4RailsMapquest.prototype.createMarkerImage = function(markerPicture, markerSize, origin, anchor, scaledSize) {};
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.mapquest.js - About 35 mins to fix

Method syncdown_note_failed has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def syncdown_note_failed(provider, guid, title, username, error = 'failed')
Severity: Minor
Found in app/mailers/cloud_note_mailer.rb - About 35 mins to fix

Method blurbify has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def blurbify(text, books = [], books_citation_style = 'citation.book.inline_unlinked_html', links_citation_style = 'citation.link.inline_unlinked_html', strip_tags = true)
Severity: Minor
Found in app/helpers/formatting_helper.rb - About 35 mins to fix

Method blurb has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def blurb(main_title, subtitle, clean_body, introduction = nil, blurb_length = NB.blurb_length.to_i, omission: NB.blurb_omission)
Severity: Minor
Found in app/helpers/blurb_helper.rb - About 35 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

Function createMarkerImage has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    Gmaps4RailsGoogle.prototype.createMarkerImage = function(markerPicture, markerSize, origin, anchor, scaledSize) {
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js - About 35 mins to fix

Method index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    page_number = params[:page] ||= 1
    all_citations = Note.citation.publishable

    @citations = all_citations.page(page_number).per(NB.citations_index_per_page.to_i).load
Severity: Minor
Found in app/controllers/citations_controller.rb - About 35 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 tweet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def self.tweet(text)
    # Replace @ and # characters before tweeting to avoid spamming other users
    #  These characters are unchanged as far as Pantography itself goes; they are stored intact.
    text = self.unspamify(text)
    tweet = authenticated_twitter_client.update(text)
Severity: Minor
Found in app/models/pantograph.rb - About 35 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 crop_offsets_by_gravity has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def crop_offsets_by_gravity(gravity, original_dimensions, cropped_dimensions)
    fail(ArgumentError, "Gravity must be one of #{GRAVITY_TYPES.inspect}") unless GRAVITY_TYPES.include?(gravity.to_sym)
    fail(ArgumentError, 'Original dimensions must be supplied as a [ width, height ] array') unless original_dimensions.is_a?(Enumerable) && original_dimensions.size == 2
    fail(ArgumentError, 'Cropped dimensions must be supplied as a [ width, height ] array') unless cropped_dimensions.is_a?(Enumerable) && cropped_dimensions.size == 2

Severity: Minor
Found in app/helpers/resources_helper.rb - About 35 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 sync_binary has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def sync_binary
    unless File.file?(raw_location)
      NB.stream_binaries == 'true' ? stream_binary : download_binary
      # Check that the resource has been downloaded correctly. If so, unflag it.
      if Digest::MD5.file(raw_location).digest == data_hash
Severity: Minor
Found in app/models/resource.rb - About 35 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 discard_versions? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def discard_versions?
    if has_instruction?('reset')
      self.external_updated_at = external_created_at if NB.always_reset_on_create == 'true'
      versions.destroy_all unless versions.empty?
    end
Severity: Minor
Found in app/models/note.rb - About 25 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 populate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def populate(response)
    response = response['data'].first
    metadata = {}

    metadata['title']           = response.try { |r| r['title'].titlecase }
Severity: Minor
Found in app/models/isbndb_request.rb - About 25 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 skipped has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.skipped(text)
    # Calculate the number of pantographs that have been skipped due to repeated spaces.
    #  This is basically a triangular function on the length of the string - 1.
    #  So, for a string that is five letters long, we do 4 + 3 + 2 + 1.
    return 0 if text.length == 1 && alphabet.index(text.last) > alphabet.index(' ')
Severity: Minor
Found in app/models/pantograph.rb - About 25 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

Severity
Category
Status
Source
Language