amatriain/feedbunch

View on GitHub
FeedBunch-app/app/clients/feed_client.rb

Summary

Maintainability
C
1 day
Test Coverage

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

Method fetch_valid_feed has 39 lines of code (exceeds 25 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 1 hr to fix

    Method default_fetch has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.default_fetch(url, http_caching)
        if http_caching
          Rails.logger.info "Fetching URL #{url} using HTTP caching if possible"
          RestClient.enable Rack::Cache,
                            verbose: false,
    Severity: Minor
    Found in FeedBunch-app/app/clients/feed_client.rb - About 1 hr to fix

      Method default_fetch has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.default_fetch(url, http_caching)
          if http_caching
            Rails.logger.info "Fetching URL #{url} using HTTP caching if possible"
            RestClient.enable Rack::Cache,
                              verbose: false,
      Severity: Minor
      Found in FeedBunch-app/app/clients/feed_client.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 fix_encoding has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.fix_encoding(feed_response)
          return nil if feed_response.nil?
      
          # Detect encoding from HTTP content-type header, in case RestClient has detected the wrong encoding
          headers = feed_response.try :headers
      Severity: Minor
      Found in FeedBunch-app/app/clients/feed_client.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

      There are no issues that match your filters.

      Category
      Status