joegattnet/joegattnet_v3

View on GitHub

Showing 103 of 103 total issues

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 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

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 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

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 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 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 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 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  def _vertical_offset(gravity, original_height, cropped_height)
    case gravity
    when :north_west, :north, :north_east then 0
    when :center, :east, :west then [((original_height - cropped_height) / 2.0).to_i, 0].max
    when :south_west, :south, :south_east then (original_height - cropped_height).to_i
Severity: Minor
Found in app/helpers/resources_helper.rb and 1 other location - About 30 mins to fix
app/helpers/resources_helper.rb on lines 146..150

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 33.

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

  def _horizontal_offset(gravity, original_width, cropped_width)
    case gravity
    when :north_west, :west, :south_west then 0
    when :center, :north, :south then [((original_width - cropped_width) / 2.0).to_i, 0].max
    when :north_east, :east, :south_east then (original_width - cropped_width).to_i
Severity: Minor
Found in app/helpers/resources_helper.rb and 1 other location - About 30 mins to fix
app/helpers/resources_helper.rb on lines 154..158

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 33.

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

    Gmaps4RailsBing.prototype.centerMapOnUser = function() {
      return this.serviceObject.setView({
        center: this.userLocation
      });
    };
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.bing.js and 1 other location - About 30 mins to fix
public/javascripts/gmaps4rails/gmaps4rails.bing.js on lines 190..194

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 45.

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

    Gmaps4RailsBing.prototype.fitBounds = function() {
      return this.serviceObject.setView({
        bounds: this.boundsObject
      });
    };
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.bing.js and 1 other location - About 30 mins to fix
public/javascripts/gmaps4rails/gmaps4rails.bing.js on lines 204..208

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 45.

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 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 make_local_file_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def make_local_file_name
    if mime && mime !~ /image/
      new_name = File.basename(file_name, File.extname(file_name))
    elsif caption && !caption[/[a-zA-Z\-]{5,}/].blank? # Ensure caption is in Latin script and at least 5 characters
      new_name = caption[0..NB.images_name_length.to_i]
Severity: Minor
Found in app/models/resource.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 show has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def show
    @notes = Note.publishable.where(feature: params[:feature], lang: I18n.locale)

    if @notes.empty?
      flash[:error] = "404 error! #{ request.url } does not exist."
Severity: Minor
Found in app/controllers/features_controller.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 show_feature has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def show_feature
    @note = params[:feature_id].nil? ? @notes.first : @notes.where(feature_id: params[:feature_id]).first
    note_tags(@note)
    commontator_thread_show(@note)
    @map = mapify(@note) if @note.has_instruction?('map') && !@note.inferred_latitude.nil?
Severity: Minor
Found in app/controllers/features_controller.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 author_surname has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def author_surname
    return nil if author.blank? && editor.blank?
    surname = (author.blank? ? editor : author).split(',')[0].scan(/([^ ]*)$/)[0][0]
    author.blank? ? "#{ surname } #{ I18n.t('books.show.editor_short') }" : surname
  end
Severity: Minor
Found in app/models/book.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