amatriain/feedbunch

View on GitHub

Showing 67 of 122 total issues

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

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

      def reset_folders(demo_user)
        already_existing_default_folders = []
        not_existing_default_folders = []
    
        # Find out which folders are already created and which ones are not
    Severity: Minor
    Found in FeedBunch-app/app/workers/reset_demo_user_worker.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 index has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def index
        @include_read = param_str_to_boolean :include_read, params
    
        if params[:feed_id].present?
          index_feed
    Severity: Minor
    Found in FeedBunch-app/app/controllers/api/entries_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

    Method show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def show
        @subscription = FeedSubscription.find_by user_id: current_user.id, feed_id: params[:id]
    
        if @subscription.present?
          # If feed subscription has not changed, return a 304
    Severity: Minor
    Found in FeedBunch-app/app/controllers/api/feeds_controller.rb - About 45 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 feed_schedule_count has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def self.feed_schedule_count(feed_id, queued_ids, scheduled_ids, retry_ids, worker_ids)
    Severity: Minor
    Found in FeedBunch-app/lib/schedule_manager.rb - About 35 mins to fix

      Method up has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def up
          rename_column :entries, :content_hash, :unique_hash
          change_column_default :entries, :unique_hash, ''
          remove_index :entries, name: "index_entries_on_guid_feed_id"
          add_index :entries, [:feed_id, :unique_hash, :guid], name: 'index_feedid_guid_hash_on_entries'

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

        def self.convert(code, locale)
          if code.chr =~ /^[[:alnum:]]$/
            str = code.chr
          else
            unless I18n.available_locales.include? locale
      Severity: Minor
      Found in FeedBunch-app/lib/keycode_to_string_converter.rb - About 35 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 show has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def show
          @folder = current_user.folders.find params[:id]
      
          if @folder.present?
            # If folder has not changed, return a 304
      Severity: Minor
      Found in FeedBunch-app/app/controllers/api/folders_controller.rb - About 35 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 refresh has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.refresh(feed, user)
          # If feed has never fetched, refresh it.
          if feed.last_fetched.blank?
            refresh_feed = true
          else
      Severity: Minor
      Found in FeedBunch-app/lib/feed_refresh_manager.rb - About 35 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 default_attribute_values has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def default_attribute_values
          # GUID defaults to the url attribute
          self.guid = self.url if self.guid.blank?
      
          # title defaults to the url attribute
      Severity: Minor
      Found in FeedBunch-app/app/models/entry.rb - About 35 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 notify_error has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.notify_error(user, error=nil)
          # If an exception is raised, set the import process state to ERROR
          if user.present?
            user.create_opml_import_job_state if user.opml_import_job_state.blank?
            user.opml_import_job_state.update state: OpmlImportJobState::ERROR
      Severity: Minor
      Found in FeedBunch-app/lib/opml_import_notifier.rb - About 35 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 perform has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def perform(user_id)
          # Check if the user actually exists
          if !User.exists? user_id
            Rails.logger.error "Trying to export OPML file for non-existing user #{user_id}"
            return
      Severity: Minor
      Found in FeedBunch-app/app/workers/export_subscriptions_worker.rb - About 35 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 index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def index
          # If subscribe job states have not changed, return a 304
          if stale? etag: EtagCalculator.etag(current_user.subscribe_jobs_updated_at),
                    last_modified: current_user.subscribe_jobs_updated_at
            if SubscribeJobState.exists? user_id: current_user.id
      Severity: Minor
      Found in FeedBunch-app/app/controllers/api/subscribe_job_states_controller.rb - About 35 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 index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def index
          # If refresh feed job states have not changed, return a 304
          if stale? etag: EtagCalculator.etag(current_user.refresh_feed_jobs_updated_at),
                    last_modified: current_user.refresh_feed_jobs_updated_at
            if RefreshFeedJobState.exists? user_id: current_user.id
      Severity: Minor
      Found in FeedBunch-app/app/controllers/api/refresh_feed_job_states_controller.rb - About 35 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

      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

        Method update_config has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def update_config(show_main_tour: nil, show_mobile_tour: nil, show_feed_tour: nil, show_entry_tour: nil,
                            show_kb_shortcuts_tour: nil)
            new_config = {}
            new_config[:show_main_tour] = show_main_tour if !show_main_tour.nil?
            new_config[:show_mobile_tour] = show_mobile_tour if !show_mobile_tour.nil?
        Severity: Minor
        Found in FeedBunch-app/app/models/user.rb - About 25 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

        Severity
        Category
        Status
        Source
        Language