amatriain/openreader

View on GitHub

Showing 122 of 122 total issues

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

  def entry_deleted
    if Entry.where('feed_id = ? AND (guid = ? OR unique_hash = ?)', self.feed_id, self.guid, self.unique_hash).exists?
      Rails.logger.warn "Failed attempt to mark as deleted existing entry - guid: #{self.try :guid}, unique_hash: #{self.try :unique_hash}, published: #{self.try :published}, feed_id: #{self.feed_id}, feed title: #{self.feed.title}"
      errors.add :base, 'entry not deleted'
Severity: Minor
Found in FeedBunch-app/app/models/deleted_entry.rb and 1 other location - About 55 mins to fix
FeedBunch-app/app/models/entry.rb on lines 139..142

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

  def reset_folders(demo_user)
    already_existing_default_folders = []
    not_existing_default_folders = []

    # Find out which folders are already created and which ones are not
Severity: Minor
Found in FeedBunch-app/app/workers/reset_demo_user_worker.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 folder_entries has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def self.folder_entries(folder, user, include_read: false, page: nil)
    if folder == Folder::ALL_FOLDERS
      if include_read && !page.present?
        entries = user.entries.order 'entries.published desc, entries.created_at desc, entries.id desc'
      elsif include_read && page.present?
Severity: Minor
Found in FeedBunch-app/lib/entries_pagination.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

  def down
    add_column :users, :subscribe_jobs_updated_at, :datetime, null: true
    add_column :users, :refresh_feed_jobs_updated_at, :datetime, null: true

    User.all.each do |u|
FeedBunch-app/db/migrate/20150206150041_change_job_etag_to_last_modified.rb on lines 2..13

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

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 up
    add_column :users, :subscribe_jobs_updated_at, :datetime, null: true
    add_column :users, :refresh_feed_jobs_updated_at, :datetime, null: true

    User.all.each do |u|
FeedBunch-app/db/migrate/20150127180808_change_job_last_modified_to_etag.rb on lines 18..29

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

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

  def show
    @subscription = FeedSubscription.find_by user_id: current_user.id, feed_id: params[:id]

    if @subscription.present?
      # If feed subscription has not changed, return a 304
Severity: Minor
Found in FeedBunch-app/app/controllers/api/feeds_controller.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

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

  def fix_encoding
    self.title = EncodingManager.fix_encoding self.title
    self.url = EncodingManager.fix_encoding self.url
    self.author = EncodingManager.fix_encoding self.author
    self.content = EncodingManager.fix_encoding self.content
Severity: Minor
Found in FeedBunch-app/app/models/entry.rb and 1 other location - About 40 mins to fix
FeedBunch-app/app/models/entry.rb on lines 202..211

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

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 sanitize_attributes
    # Summary, content are sanitized with an HTML sanitizer, we want imgs etc to be present.
    # Other attributes are sanitized by stripping tags, they should be plain text.
    self.content = Sanitizer.sanitize_html self.content
    self.summary = Sanitizer.sanitize_html self.summary
Severity: Minor
Found in FeedBunch-app/app/models/entry.rb and 1 other location - About 40 mins to fix
FeedBunch-app/app/models/entry.rb on lines 174..180

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

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

  rescue => e
    Rails.logger.error "Error trying to export subscriptions in OPML format for user #{user.id} - #{user.email}"
    Rails.logger.error e.message
    Rails.logger.error e.backtrace
    user.opml_export_job_state&.destroy
Severity: Minor
Found in FeedBunch-app/lib/opml_exporter.rb and 1 other location - About 40 mins to fix
FeedBunch-app/lib/opml_importer.rb on lines 40..47

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

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

  rescue => e
    Rails.logger.error "Error trying to read OPML data from file uploaded by user #{user.id} - #{user.email}"
    Rails.logger.error e.message
    Rails.logger.error e.backtrace
    user.opml_import_job_state&.destroy
Severity: Minor
Found in FeedBunch-app/lib/opml_importer.rb and 1 other location - About 40 mins to fix
FeedBunch-app/lib/opml_exporter.rb on lines 28..35

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

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 feed_schedule_count has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def self.feed_schedule_count(feed_id, queued_ids, scheduled_ids, retry_ids, worker_ids)
Severity: Minor
Found in FeedBunch-app/lib/schedule_manager.rb - About 35 mins to fix

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

      def show
        @folder = current_user.folders.find params[:id]
    
        if @folder.present?
          # If folder has not changed, return a 304
    Severity: Minor
    Found in FeedBunch-app/app/controllers/api/folders_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 perform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def perform(user_id)
        # Check if the user actually exists
        if !User.exists? user_id
          Rails.logger.error "Trying to export OPML file for non-existing user #{user_id}"
          return
    Severity: Minor
    Found in FeedBunch-app/app/workers/export_subscriptions_worker.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
        # If subscribe job states have not changed, return a 304
        if stale? etag: EtagCalculator.etag(current_user.subscribe_jobs_updated_at),
                  last_modified: current_user.subscribe_jobs_updated_at
          if SubscribeJobState.exists? user_id: current_user.id
    Severity: Minor
    Found in FeedBunch-app/app/controllers/api/subscribe_job_states_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 index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def index
        # If refresh feed job states have not changed, return a 304
        if stale? etag: EtagCalculator.etag(current_user.refresh_feed_jobs_updated_at),
                  last_modified: current_user.refresh_feed_jobs_updated_at
          if RefreshFeedJobState.exists? user_id: current_user.id
    Severity: Minor
    Found in FeedBunch-app/app/controllers/api/refresh_feed_job_states_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 up has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def up
        rename_column :entries, :content_hash, :unique_hash
        change_column_default :entries, :unique_hash, ''
        remove_index :entries, name: "index_entries_on_guid_feed_id"
        add_index :entries, [:feed_id, :unique_hash, :guid], name: 'index_feedid_guid_hash_on_entries'

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

      def self.notify_error(user, error=nil)
        # If an exception is raised, set the import process state to ERROR
        if user.present?
          user.create_opml_import_job_state if user.opml_import_job_state.blank?
          user.opml_import_job_state.update state: OpmlImportJobState::ERROR
    Severity: Minor
    Found in FeedBunch-app/lib/opml_import_notifier.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 default_attribute_values has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def default_attribute_values
        # GUID defaults to the url attribute
        self.guid = self.url if self.guid.blank?
    
        # title defaults to the url attribute
    Severity: Minor
    Found in FeedBunch-app/app/models/entry.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 refresh has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.refresh(feed, user)
        # If feed has never fetched, refresh it.
        if feed.last_fetched.blank?
          refresh_feed = true
        else
    Severity: Minor
    Found in FeedBunch-app/lib/feed_refresh_manager.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 convert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.convert(code, locale)
        if code.chr =~ /^[[:alnum:]]$/
          str = code.chr
        else
          unless I18n.available_locales.include? locale
    Severity: Minor
    Found in FeedBunch-app/lib/keycode_to_string_converter.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

    Severity
    Category
    Status
    Source
    Language