amatriain/feedbunch

View on GitHub

Showing 122 of 122 total issues

Method discover has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.discover(feed, feed_response)
    Rails.logger.info "Trying to perform feed autodiscovery on url #{feed.fetch_url}"
    doc = Nokogiri::HTML feed_response

    # In this order, give preference to Atom, then to RSS, then to generic "feed" links
Severity: Minor
Found in FeedBunch-app/lib/feed_autodiscovery.rb - About 1 hr to fix

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

      def up
        add_column :users, :subscribe_jobs_etag, :text, null: true
        add_column :users, :refresh_feed_jobs_etag, :text, null: true
    
        User.all.each do |u|
    FeedBunch-app/db/migrate/20150206150041_change_job_etag_to_last_modified.rb on lines 15..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 56.

    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 down
        add_column :users, :subscribe_jobs_etag, :text, null: true
        add_column :users, :refresh_feed_jobs_etag, :text, null: true
    
        User.all.each do |u|
    FeedBunch-app/db/migrate/20150127180808_change_job_last_modified_to_etag.rb on lines 2..16

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

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

      def before_save_user
        self.encrypted_password.encode! 'utf-8'
    
        # If demo is enabled, demo user cannot change email or password nor be locked
        if Feedbunch::Application.config.demo_enabled
    Severity: Minor
    Found in FeedBunch-app/app/models/user.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 class_for_url has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.class_for_url(url, type)
        return nil if url.blank?
        return nil if type!=HANDLER && type!=FETCHER
    
        # Add uri-scheme if missing, convert to downcase and remove extra whitespaces so that it can be parsed
    Severity: Minor
    Found in FeedBunch-app/lib/special_feed_manager.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 change has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def change
        change_column_null :active_admin_comments, :created_at, false, Time.zone.now
        change_column_null :active_admin_comments, :updated_at, false
    
        add_timestamps :deleted_entries, null: true
    Severity: Minor
    Found in FeedBunch-app/db/migrate/20150106110953_not_null_timestamps.rb - About 1 hr to fix

      Method change has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def change
          remove_foreign_key :deleted_entries, :feeds
          remove_foreign_key :entries, :feeds
          remove_foreign_key :entry_states, :entries
          remove_foreign_key :entry_states, :users

        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

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

            def self.increment_update_interval(feed)
              new_interval = (feed.fetch_interval_secs * 1.1).round
              max = Feedbunch::Application.config.max_update_interval
              new_interval = max if new_interval > max
          
          
          Severity: Major
          Found in FeedBunch-app/lib/schedule_manager.rb and 1 other location - About 1 hr to fix
          FeedBunch-app/lib/schedule_manager.rb on lines 111..125

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

          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 self.decrement_update_interval(feed)
              new_interval = (feed.fetch_interval_secs * 0.9).round
              min = Feedbunch::Application.config.min_update_interval
              new_interval = min if new_interval < min
          
          
          Severity: Major
          Found in FeedBunch-app/lib/schedule_manager.rb and 1 other location - About 1 hr to fix
          FeedBunch-app/lib/schedule_manager.rb on lines 133..147

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

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

            def self.fix_scheduled_updates
              Rails.logger.debug 'Fixing scheduled feed updates'
          
              queue = Sidekiq::Queue.new 'update_feeds'
              queued_ids = queue.select{|job| job.klass == 'ScheduledUpdateFeedWorker'}.map{|job| job.args[0]}
          Severity: Minor
          Found in FeedBunch-app/lib/schedule_manager.rb - About 1 hr to fix

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

              def index_feeds
                if @feeds.present?
                  # Compose an array; each element is a hash containing the data necessary to render a feed in the JSON response
                  @feeds_data = []
                  @feeds.each do |feed|
            Severity: Minor
            Found in FeedBunch-app/app/controllers/api/feeds_controller.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 folder_feeds has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

              def self.folder_feeds(folder, user, include_read: false)
                if folder == Folder::NO_FOLDER
                  feeds = Feed.arel_table
                  folders = Folder.arel_table
                  feed_subscriptions = FeedSubscription.arel_table
            Severity: Minor
            Found in FeedBunch-app/lib/folder_manager.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 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 export has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def self.export(user)
                # Compose the OPML file (actually XML)
                feeds_outside_folders = user.folder_feeds Folder::NO_FOLDER, include_read: true
                # Sort feeds by title, mainly for easier testing
                feeds_outside_folders.sort_by!{|a| a.title}
            Severity: Minor
            Found in FeedBunch-app/lib/opml_exporter.rb - About 1 hr to fix

              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

              Method entry_to_hash has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def self.entry_to_hash(entry, guid)
                  # Some feed parser types do not give a "content" attribute to their entries. In
                  # this case we default to the entry summary.
                  if entry.respond_to? :content
                    content = entry.content
              Severity: Minor
              Found in FeedBunch-app/lib/entry_manager.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

              Method handle_error has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def handle_error(error)
                  if error.is_a? ActiveRecord::RecordNotFound
                    head 404
                  elsif error.is_a? AlreadySubscribedError
                    # If user is already subscribed to the feed, return 304
              Severity: Minor
              Found in FeedBunch-app/app/controllers/application_controller.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 entry_not_deleted
                  if DeletedEntry.where('feed_id = ? AND (guid = ? OR unique_hash = ?)', self.feed_id, self.guid, self.unique_hash).exists?
                    Rails.logger.debug "Entry not valid: already deleted 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 already deleted'
              Severity: Minor
              Found in FeedBunch-app/app/models/entry.rb and 1 other location - About 55 mins to fix
              FeedBunch-app/app/models/deleted_entry.rb on lines 43..46

              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

              Severity
              Category
              Status
              Source
              Language