amatriain/feedbunch

View on GitHub

Showing 122 of 122 total issues

Method convert has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def self.convert(code, locale)
    if code.chr =~ /^[[:alnum:]]$/
      str = code.chr
    else
      unless I18n.available_locales.include? locale
Severity: Major
Found in FeedBunch-app/lib/keycode_to_string_converter.rb - About 2 hrs to fix

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

      def show
        if OpmlExportJobState.exists? user_id: current_user.id
          @opml_export_job_state = OpmlExportJobState.find_by user_id: current_user.id
        else
          Rails.logger.warn "User #{current_user.id} - #{current_user.email} has no OpmlExportJobState, creating one with state NONE"
    Severity: Major
    Found in FeedBunch-app/app/controllers/api/opml_exports_controller.rb and 1 other location - About 2 hrs to fix
    FeedBunch-app/app/controllers/api/opml_imports_controller.rb on lines 18..34

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

    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 show
        if OpmlImportJobState.exists? user_id: current_user.id
          @opml_import_job_state = OpmlImportJobState.find_by user_id: current_user.id
        else
          Rails.logger.warn "User #{current_user.id} - #{current_user.email} has no OpmlImportJobState, creating one with state NONE"
    Severity: Major
    Found in FeedBunch-app/app/controllers/api/opml_imports_controller.rb and 1 other location - About 2 hrs to fix
    FeedBunch-app/app/controllers/api/opml_exports_controller.rb on lines 19..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 77.

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

      def self.change_entries_state(entry, state, user, whole_feed: false, whole_folder: false, all_entries: false)
        if state == 'read'
          read = true
        elsif state == 'unread'
          read = false
    Severity: Minor
    Found in FeedBunch-app/lib/entry_state_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 reset_feed_subscriptions has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      def reset_feed_subscriptions(demo_user)
        already_subscribed_default_feeds = []
        not_subscribed_default_feeds = []
    
        Feedbunch::Application.config.demo_subscriptions.keys.each do |folder|
    Severity: Minor
    Found in FeedBunch-app/app/workers/reset_demo_user_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 perform has 43 lines of code (exceeds 25 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 1 hr to fix

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

        def self.send_second_confirmation_reminders
          signups_older_than = Time.zone.now - Feedbunch::Application.config.second_confirmation_reminder_after
          Rails.logger.info "Sending second confirmation reminder to unconfirmed users signed up before #{signups_older_than}"
      
          old_unconfirmed_signups = User.
      Severity: Major
      Found in FeedBunch-app/lib/signups_manager.rb and 1 other location - About 1 hr to fix
      FeedBunch-app/lib/signups_manager.rb on lines 53..71

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

      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.send_first_confirmation_reminders
          signups_older_than = Time.zone.now - Feedbunch::Application.config.first_confirmation_reminder_after
          Rails.logger.info "Sending first confirmation reminder to unconfirmed users signed up before #{signups_older_than}"
      
          old_unconfirmed_signups = User.
      Severity: Major
      Found in FeedBunch-app/lib/signups_manager.rb and 1 other location - About 1 hr to fix
      FeedBunch-app/lib/signups_manager.rb on lines 81..99

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

      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 discover has a Cognitive Complexity of 13 (exceeds 5 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

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

          def self.fetch_feed(url)
            Rails.logger.info "URL #{url} belongs to a Tumblr domain possibly with a GDPR interstitial page, using a full browser to fetch it"
        
            if Feedbunch::Application.config.headless_browser_location == 'remote'
              Rails.logger.info "Using a remote browser in host #{Feedbunch::Application.config.headless_browser_host}, port #{Feedbunch::Application.config.headless_browser_port}"
        Severity: Minor
        Found in FeedBunch-app/lib/tumblr_feed_fetcher.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 folder_feeds has 37 lines of code (exceeds 25 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

              Method reset_feed_subscriptions has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def reset_feed_subscriptions(demo_user)
                  already_subscribed_default_feeds = []
                  not_subscribed_default_feeds = []
              
                  Feedbunch::Application.config.demo_subscriptions.keys.each do |folder|
              Severity: Minor
              Found in FeedBunch-app/app/workers/reset_demo_user_worker.rb - About 1 hr to fix

                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 save_new_entries has 35 lines of code (exceeds 25 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 1 hr to fix

                    Method process_opml has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def self.process_opml(filename, user)
                        # Open file and check if it actually exists
                        xml_contents = Feedbunch::Application.config.uploads_manager.read user.id, FOLDER, filename
                        if xml_contents == nil
                          Rails.logger.error "Trying to import for user #{user.id} from non-existing OPML file: #{filename}"
                    Severity: Minor
                    Found in FeedBunch-app/lib/opml_importer.rb - About 1 hr to fix

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

                        Consider simplifying this complex logical expression.
                        Open

                            if saved_change_to_quick_reading? || saved_change_to_open_all_entries? ||
                                saved_change_to_show_main_tour? || saved_change_to_show_mobile_tour? ||
                                saved_change_to_show_feed_tour? || saved_change_to_show_entry_tour? ||
                                saved_change_to_show_kb_shortcuts_tour? || saved_change_to_kb_shortcuts_enabled?
                              update_column :config_updated_at, Time.zone.now
                        Severity: Critical
                        Found in FeedBunch-app/app/models/user.rb - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language