amatriain/feedbunch

View on GitHub

Showing 122 of 122 total issues

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

  req.onreadystatechange = function(e) {
    if (req.readyState == XMLHttpRequest.DONE) {
      if (req.status == 0) {
        // Network error, retry up to max_retries times
        if (retry_count < max_retries) {
FeedBunch-app/app/assets/javascripts/workers/common/do_get.js on lines 16..37

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

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

  req.onreadystatechange = function(e) {
    if (req.readyState == XMLHttpRequest.DONE) {
      if (req.status == 0) {
        // Network error, retry up to max_retries times
        if (retry_count < max_retries) {
FeedBunch-app/app/assets/javascripts/workers/common/do_post.js on lines 16..37

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

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

  req.onreadystatechange = function(e) {
    if (req.readyState == XMLHttpRequest.DONE) {
      if (req.status == 0) {
        // Network error, retry up to max_retries times
        if (retry_count < max_retries) {
FeedBunch-app/app/assets/javascripts/workers/common/do_put.js on lines 16..33

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

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

  req.onreadystatechange = function(e) {
    if (req.readyState == XMLHttpRequest.DONE) {
      if (req.status == 0) {
        // Network error, retry up to max_retries times
        if (retry_count < max_retries) {
FeedBunch-app/app/assets/javascripts/workers/common/do_delete.js on lines 16..33

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

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

  def perform(refresh_feed_job_state_id, feed_id, user_id)
    # Check if refresh_feed_job_state actually exists
    job_state = nil
    if RefreshFeedJobState.exists? refresh_feed_job_state_id
      job_state = RefreshFeedJobState.find refresh_feed_job_state_id
Severity: Minor
Found in FeedBunch-app/app/workers/refresh_feed_worker.rb - About 4 hrs 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 31 (exceeds 5 allowed). Consider refactoring.
Open

  def perform(feed_id)
    # Check that feed actually exists
    if !Feed.exists? feed_id
      Rails.logger.warn "Feed #{feed_id} scheduled to be updated, but it does not exist in the database. Unscheduling further updates."
      ScheduleManager.unschedule_feed_updates feed_id
Severity: Minor
Found in FeedBunch-app/app/workers/scheduled_update_feed_worker.rb - About 4 hrs 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 fetch_valid_feed has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

  def self.fetch_valid_feed(feed, http_caching, perform_autodiscovery)
    if perform_autodiscovery
      Rails.logger.info "Performing autodiscovery on feed #{feed.id} - URL #{feed.url}"
      url = feed.url
    else
Severity: Minor
Found in FeedBunch-app/app/clients/feed_client.rb - About 4 hrs 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

class Api::RefreshFeedJobStatesController < ApplicationController

  before_action :authenticate_user!

  respond_to :json
FeedBunch-app/app/controllers/api/subscribe_job_states_controller.rb on lines 8..57

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

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

class Api::SubscribeJobStatesController < ApplicationController

  before_action :authenticate_user!

  respond_to :json
FeedBunch-app/app/controllers/api/refresh_feed_job_states_controller.rb on lines 8..57

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

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 default_values has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def default_values
    # Convert the symbols for the available locales to strings, to be able to compare with the user locale
    # NOTE.- don't do the opposite (converting the user locale to a symbol before checking if it's included in the
    # array of available locales) because memory allocated for symbols is never released by ruby, which means an
    # attacker could cause a memory leak by creating users with weird unavailable locales.
Severity: Major
Found in FeedBunch-app/app/models/user.rb - About 3 hrs to fix

    Class User has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class User < ApplicationRecord
    
      # Include default devise modules. Others available are:
      # :token_authenticatable, :confirmable,
      # :lockable, :timeoutable and :omniauthable
    Severity: Minor
    Found in FeedBunch-app/app/models/user.rb - About 3 hrs to fix

      Method perform has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def perform(feed_id)
          # Check that feed actually exists
          if !Feed.exists? feed_id
            Rails.logger.warn "Feed #{feed_id} scheduled to be updated, but it does not exist in the database. Unscheduling further updates."
            ScheduleManager.unschedule_feed_updates feed_id
      Severity: Major
      Found in FeedBunch-app/app/workers/scheduled_update_feed_worker.rb - About 3 hrs to fix

        Method save_new_entries has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.save_new_entries(feed, entries, encoding)
            entries.reverse_each do |entry_parsed|
        
              begin
                guid = entry_parsed.entry_id || entry_parsed.url
        Severity: Minor
        Found in FeedBunch-app/lib/entry_manager.rb - About 2 hrs 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_values has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

          def default_values
            # Convert the symbols for the available locales to strings, to be able to compare with the user locale
            # NOTE.- don't do the opposite (converting the user locale to a symbol before checking if it's included in the
            # array of available locales) because memory allocated for symbols is never released by ruby, which means an
            # attacker could cause a memory leak by creating users with weird unavailable locales.
        Severity: Minor
        Found in FeedBunch-app/app/models/user.rb - About 2 hrs 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 change has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          def change
            Entry.all.find_each do |entry|
              begin
                entry.title = entry.title.try(:strip) if entry.title != entry.title.try(:strip)
                entry.url = entry.url.try(:strip) if entry.url != entry.url.try(:strip)
        Severity: Minor
        Found in FeedBunch-app/db/migrate/20131213124416_trim_entry_strings.rb - About 2 hrs 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

        File user.rb has 274 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'folder_manager'
        require 'url_subscriber'
        require 'feed_refresh_manager'
        require 'entry_state_manager'
        require 'entries_pagination'
        Severity: Minor
        Found in FeedBunch-app/app/models/user.rb - About 2 hrs to fix

          Method perform has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def perform(user_id, feed_url, job_state_id)
              # Find the SubscribeJobState instance for this job, if it exists
              if SubscribeJobState.exists? job_state_id
                job_state = SubscribeJobState.find job_state_id
                # Check that the subscribe_job_state is in state "RUNNING"
          Severity: Minor
          Found in FeedBunch-app/app/workers/subscribe_user_worker.rb - About 2 hrs 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 normalize_entry_url has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.normalize_entry_url(url, entry)
              # Check that the passed string contains something
              return nil if url.blank?
          
              normalized_url = strip_url url
          Severity: Minor
          Found in FeedBunch-app/lib/url_normalizer.rb - About 2 hrs 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 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def perform(refresh_feed_job_state_id, feed_id, user_id)
              # Check if refresh_feed_job_state actually exists
              job_state = nil
              if RefreshFeedJobState.exists? refresh_feed_job_state_id
                job_state = RefreshFeedJobState.find refresh_feed_job_state_id
          Severity: Major
          Found in FeedBunch-app/app/workers/refresh_feed_worker.rb - About 2 hrs to fix

            Class Entry has 21 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class Entry < ApplicationRecord
            
              LOADING_IMAGE_GIF = '/images/Ajax-loader.gif'
            
              belongs_to :feed
            Severity: Minor
            Found in FeedBunch-app/app/models/entry.rb - About 2 hrs to fix
              Severity
              Category
              Status
              Source
              Language