3scale/porta

View on GitHub
features/support/paths.rb

Summary

Maintainability
F
3 days
Test Coverage

Method path_to has 495 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def path_to(page_name, *args) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
    case page_name

    # Public
    when /the home\s?page/
Severity: Major
Found in features/support/paths.rb - About 2 days to fix

    File paths.rb has 504 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    World(Module.new do
      break unless defined?(DeveloperPortal)
    
      include System::UrlHelpers.cms_url_helpers
    
    
    Severity: Major
    Found in features/support/paths.rb - About 1 day to fix

      Method path_to has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Wontfix

        def path_to(page_name, *args) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
          case page_name
      
          # Public
          when /the home\s?page/
      Severity: Minor
      Found in features/support/paths.rb - About 2 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

      path_to has approx 254 statements
      Open

        def path_to(page_name, *args) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
      Severity: Minor
      Found in features/support/paths.rb by reek

      A method with Too Many Statements is any method that has a large number of lines.

      Too Many Statements warns about any method that has more than 5 statements. Reek's smell detector for Too Many Statements counts +1 for every simple statement in a method and +1 for every statement within a control structure (if, else, case, when, for, while, until, begin, rescue) but it doesn't count the control structure itself.

      So the following method would score +6 in Reek's statement-counting algorithm:

      def parse(arg, argv, &error)
        if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
          return nil, block, nil                                         # +1
        end
        opt = (val = parse_arg(val, &error))[1]                          # +2
        val = conv_arg(*val)                                             # +3
        if opt and !arg
          argv.shift                                                     # +4
        else
          val[0] = nil                                                   # +5
        end
        val                                                              # +6
      end

      (You might argue that the two assigments within the first @if@ should count as statements, and that perhaps the nested assignment should count as +2.)

      path_to calls 'Account.buyers.find_by!(org_name: $3)' 2 times
      Open

              admin_buyers_account_applications_path(Account.buyers.find_by!(org_name: $3), per_page: $4)
            when 'product'
              admin_service_applications_path(Service.find_by!(name: $3), per_page: $4)
            when 'the admin portal'
              provider_admin_applications_path(per_page: $4)
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'Account.find_by!(org_name: $1)' 2 times
      Open

            admin_buyers_account_path(Account.find_by!(org_name: $1))
      
          when /^the buyer account edit page for "([^"]*)"$/,
               /^the buyer account "([^"]*)" edit page$/
            edit_admin_buyers_account_path(Account.find_by_org_name!($1))
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'Regexp.last_match(1)' 2 times
      Open

            message = @provider.sent_messages.find_by(subject: Regexp.last_match(1))
            provider_admin_messages_outbox_path(message)
      
          when "the outbox compose page"
            new_provider_admin_messages_outbox_path
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'Topic.find_by_title!($1)' 3 times
      Open

            forum_topic_path(Topic.find_by_title!($1))
          when 'the forum subscriptions page'
            forum_subscriptions_path
      
          #
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'account.messages.build(body: 'foo', subject: 'bar')' 2 times
      Open

            message = account.messages.build(body: 'foo', subject: 'bar')
            message.to current_account
            message.deliver
            admin_messages_inbox_path(message.recipients[0])
      
      
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'BackendApi.find_by!(name: $1)' 3 times
      Wontfix

            provider_admin_backend_api_mapping_rules_path(BackendApi.find_by!(name: $1))
          when /^the create mapping rule page for service "(.+?)"/
            service = Service.find_by!(name: $1)
            new_admin_service_proxy_rule_path(service)
          when /^the create mapping rule page for backend "(.+?)"/
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'Cinstance.find_by(name: $1)' 2 times
      Open

            app = Cinstance.find_by(name: $1) || @cinstance || @application
            admin_application_path(app)
      
          when /^(?:application "(.*)"|the application's) dev portal edit page$/
            app = Cinstance.find_by(name: $1) || @cinstance || @application
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'User.find_by_username!($1)' 4 times
      Open

            user = User.find_by_username!($1)
            edit_provider_admin_account_user_path(user)
          when /^the user edit page for "([^"]*)"$/
            user = User.find_by_username!($1)
            edit_admin_account_user_path(user)
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'Cinstance.find_by(name: $2)' 3 times
      Open

            app = Cinstance.find_by(name: $2) || @cinstance || @application
            provider_admin_application_path(app)
      
          when /^(application "(.*)"|the application's) admin edit page$/
            app = Cinstance.find_by(name: $2) || @cinstance || @application
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls '@provider.default_service' 5 times
      Open

            admin_service_api_docs_path(@provider.default_service)
          when 'the new active docs page for a service'
            new_admin_service_api_doc_path(@provider.default_service)
          when 'the preview active docs page for a service'
            service = @provider.default_service
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'account.messages' 2 times
      Open

            message = account.messages.build(body: 'foo', subject: 'bar')
            message.to current_account
            message.deliver
            admin_messages_inbox_path(message.recipients[0])
      
      
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'user.account' 2 times
      Open

            admin_buyers_account_user_path(user.account, user)
      
          when /^the buyer user edit page for "([^"]*)"$/,
               /^the buyer user "([^"]*)" edit page$/
            user = User.find_by_username!($1)
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'Service.find_by(name: $2)' 4 times
      Open

            product = Service.find_by(name: $2) || @product || @service || provider_first_service!
            admin_service_application_plans_path(product)
      
          when /^(product "(.*)"|the product's) new application plan admin page$/
            product = Service.find_by(name: $2) || @product || @service || provider_first_service!
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'Account.first' 2 times
      Open

            account = Account.first
            message = account.messages.build(body: 'foo', subject: 'bar')
            message.to current_account
            message.deliver
            admin_messages_inbox_path(message.recipients[0])
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'Service.find_by!(name: $1)' 10 times
      Wontfix

            admin_service_alerts_path(Service.find_by!(name: $1))
      
          when /^the (edit|settings) page for service "([^"]+)" of provider "(.+?)"$/
            provider = Account.providers.find_by_org_name! $3
            service = provider.services.find_by_name! $2
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'Service.find_by!(name: $3)' 2 times
      Open

              admin_service_applications_path(Service.find_by!(name: $3), per_page: $4)
            when 'the admin portal'
              provider_admin_applications_path(per_page: $4)
            end
      
      
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'message.to current_account' 2 times
      Open

            message.to current_account
            message.deliver
            admin_messages_inbox_path(message.recipients[0])
      
          when "the outbox show page"
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'Account.find_by_org_name!($1)' 7 times
      Open

            edit_admin_buyers_account_path(Account.find_by_org_name!($1))
      
          when /^the buyer users page for "([^"]*)"$/,
               /^the buyer account "([^"]*)" users page$/
            admin_buyers_account_users_path(Account.find_by_org_name!($1))
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'Account.buyers' 2 times
      Wontfix

              admin_buyers_account_applications_path(Account.buyers.find_by!(org_name: $3), per_page: $4)
            when 'product'
              admin_service_applications_path(Service.find_by!(name: $3), per_page: $4)
            when 'the admin portal'
              provider_admin_applications_path(per_page: $4)
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'message.deliver' 2 times
      Open

            message.deliver
            admin_messages_inbox_path(message.recipients[0])
      
          when "the outbox show page"
            message = current_account.messages.build(body: 'foo', subject: 'bar')
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      path_to calls 'Service.find_by!(name: $2)' 2 times
      Wontfix

            product = Service.find_by!(name: $2)
            config = product.backend_api_configs
                            .references(:backend_api)
                            .includes(:backend_api)
                            .find_by!("backend_apis.name" => $1)
      Severity: Minor
      Found in features/support/paths.rb by reek

      Duplication occurs when two fragments of code look nearly identical, or when two fragments of code have nearly identical effects at some conceptual level.

      Reek implements a check for Duplicate Method Call.

      Example

      Here's a very much simplified and contrived example. The following method will report a warning:

      def double_thing()
        @other.thing + @other.thing
      end

      One quick approach to silence Reek would be to refactor the code thus:

      def double_thing()
        thing = @other.thing
        thing + thing
      end

      A slightly different approach would be to replace all calls of double_thing by calls to @other.double_thing:

      class Other
        def double_thing()
          thing + thing
        end
      end

      The approach you take will depend on balancing other factors in your code.

      There are no issues that match your filters.

      Category
      Status