amatriain/feedbunch

View on GitHub
FeedBunch-app/app/workers/import_subscription_worker.rb

Summary

Maintainability
B
4 hrs
Test Coverage

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

  def perform(opml_import_job_state_id, url, folder_id=nil)
    # Check if the opml import state actually exists
    if !OpmlImportJobState.exists? opml_import_job_state_id
      Rails.logger.error "Trying to perform ImportSubscriptionWorker as part of non-existing job state #{opml_import_job_state_id}. Aborting"
      return
Severity: Minor
Found in FeedBunch-app/app/workers/import_subscription_worker.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 import_feed has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def import_feed(user, url)
    Rails.logger.info "As part of OPML import, subscribing user #{user.id} - #{user.email} to feed #{url}"
    feed = user.subscribe url
    return feed
  rescue AlreadySubscribedError => e
Severity: Minor
Found in FeedBunch-app/app/workers/import_subscription_worker.rb - About 1 hr to fix

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

      def perform(opml_import_job_state_id, url, folder_id=nil)
        # Check if the opml import state actually exists
        if !OpmlImportJobState.exists? opml_import_job_state_id
          Rails.logger.error "Trying to perform ImportSubscriptionWorker as part of non-existing job state #{opml_import_job_state_id}. Aborting"
          return
    Severity: Minor
    Found in FeedBunch-app/app/workers/import_subscription_worker.rb - About 1 hr to fix

      Avoid too many return statements within this method.
      Open

          return nil
      Severity: Major
      Found in FeedBunch-app/app/workers/import_subscription_worker.rb - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status