3scale/porta

View on GitHub

Showing 5,269 of 5,606 total issues

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

    def modify_attributes_with_fields(attributes)
      attributes = attributes.nil? ? {} : attributes.dup

      # this is not possible, because when object is created by association,
      # then attributes like owner_id are set after initializer is run
Severity: Minor
Found in app/lib/fields/extensions.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 method_missing has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def method_missing(name, value=nil)
    key = name.to_s.sub(/[=?!]$/,'')

    if name.to_s.ends_with?("=")
      self[key] = value
Severity: Minor
Found in app/lib/three_scale/search.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 find_plans has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def find_plans
    @plans = if @plan
               [ @plan ]
             elsif @service
               @service.service_plans.published

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

  def create
    logout_keeping_session!

    return render_login_error if auth_strategy_is_internal? && !bot_check

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 _find_all has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def _find_all(name, prefix, partial, details, key = nil, locals = [])
Severity: Minor
Found in lib/developer_portal/lib/liquid/template/resolver.rb - About 45 mins to fix

    Method _find_all has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def _find_all(name, prefix, partial, details, key = nil, locals = [])
    Severity: Minor
    Found in lib/developer_portal/lib/liquid/template/fallback_resolver.rb - About 45 mins to fix

      Method _find_all has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def _find_all(name, prefix, partial, details, key = nil, locals = [])
      Severity: Minor
      Found in lib/developer_portal/lib/liquid/template/fallback_resolver_no_prefix.rb - About 45 mins to fix

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

            create_table "whitelabel_logos", :force => true do |t|
              t.integer  "parent_id"
              t.string   "content_type"
              t.string   "filename"
              t.string   "thumbnail"
        Severity: Major
        Found in db/migrate/20111128090920_dumping_unused_tables.rb and 2 other locations - About 40 mins to fix
        db/migrate/20100125103539_browser_cms_tables.rb on lines 115..125
        db/migrate/20111128090920_dumping_unused_tables.rb on lines 43..53

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

        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 3 locations. Consider refactoring.
        Open

            create_table "email_messages", :force => true do |t|
              t.string   "sender"
              t.text     "recipients"
              t.text     "subject"
              t.text     "cc"
        Severity: Major
        Found in db/migrate/20100125103539_browser_cms_tables.rb and 2 other locations - About 40 mins to fix
        db/migrate/20111128090920_dumping_unused_tables.rb on lines 43..53
        db/migrate/20111128090920_dumping_unused_tables.rb on lines 126..136

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

        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

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

            t.bigint "owner_id"
            t.string "owner_type"
            t.bigint "object_id"
            t.string "object_type"
            t.datetime "created_at", null: false
        Severity: Minor
        Found in db/schema.rb and 1 other location - About 40 mins to fix
        db/postgres_schema.rb on lines 470..478

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

        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

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

            t.bigint "owner_id"
            t.string "owner_type"
            t.bigint "object_id"
            t.string "object_type"
            t.datetime "created_at", null: false
        Severity: Minor
        Found in db/postgres_schema.rb and 1 other location - About 40 mins to fix
        db/schema.rb on lines 469..477

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

        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 3 locations. Consider refactoring.
        Open

            create_table "email_messages", :force => true do |t|
              t.string   "sender"
              t.text     "recipients"
              t.text     "subject"
              t.text     "cc"
        Severity: Major
        Found in db/migrate/20111128090920_dumping_unused_tables.rb and 2 other locations - About 40 mins to fix
        db/migrate/20100125103539_browser_cms_tables.rb on lines 115..125
        db/migrate/20111128090920_dumping_unused_tables.rb on lines 126..136

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

        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

          create_table "moderatorships", force: :cascade do |t|
            t.integer "forum_id", precision: 38
            t.integer "user_id", precision: 38
            t.datetime "created_at", precision: 6
            t.datetime "updated_at", precision: 6
        Severity: Minor
        Found in db/oracle_schema.rb and 1 other location - About 40 mins to fix
        db/oracle_schema.rb on lines 1400..1406

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

        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

          create_table "user_topics", force: :cascade do |t|
            t.integer "user_id", precision: 38
            t.integer "topic_id", precision: 38
            t.datetime "created_at", precision: 6
            t.datetime "updated_at", precision: 6
        Severity: Minor
        Found in db/oracle_schema.rb and 1 other location - About 40 mins to fix
        db/oracle_schema.rb on lines 813..819

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

        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

        Consider simplifying this complex logical expression.
        Open

          if user && user.admin?
            #COPY these come from accounts.rb
        
            # Users
            if user.account.provider? || (user.account.buyer? && user.account.provider_account.settings.try!(:useraccountarea_enabled?))
        Severity: Major
        Found in config/abilities/admin.rb - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

            if user
              # Anyone can read their own account.
              can(:read, Account) { |account| user.account == account }
          
              # redundant with one above?
          Severity: Major
          Found in config/abilities/any.rb - About 40 mins to fix

            ProxyRuleRepresenter::JSON tests 'backend_api_owner?' at least 4 times
            Open

                  if backend_api_owner?
                    admin_api_backend_api_mapping_rule_path(owner_id, id)
                  else
                    admin_api_service_proxy_mapping_rule_path(service_id, id)
                  end

            Repeated Conditional is a special case of Simulated Polymorphism. Basically it means you are checking the same value throughout a single class and take decisions based on this.

            Example

            Given

            class RepeatedConditionals
              attr_accessor :switch
            
              def repeat_1
                puts "Repeat 1!" if switch
              end
            
              def repeat_2
                puts "Repeat 2!" if switch
              end
            
              def repeat_3
                puts "Repeat 3!" if switch
              end
            end

            Reek would emit the following warning:

            test.rb -- 4 warnings:
              [5, 9, 13]:RepeatedConditionals tests switch at least 3 times (RepeatedConditional)

            If you get this warning then you are probably not using the right abstraction or even more probable, missing an additional abstraction.

            Account tests 'provider?' at least 4 times
            Open

                BackendProviderSyncWorker.enqueue(id) if provider?
              end
            
              has_many :messages, -> { visible }, foreign_key: :sender_id, class_name: 'Message'
              has_many :sent_messages, foreign_key: :sender_id, class_name: 'Message'
            Severity: Minor
            Found in app/models/account.rb by reek

            Repeated Conditional is a special case of Simulated Polymorphism. Basically it means you are checking the same value throughout a single class and take decisions based on this.

            Example

            Given

            class RepeatedConditionals
              attr_accessor :switch
            
              def repeat_1
                puts "Repeat 1!" if switch
              end
            
              def repeat_2
                puts "Repeat 2!" if switch
              end
            
              def repeat_3
                puts "Repeat 3!" if switch
              end
            end

            Reek would emit the following warning:

            test.rb -- 4 warnings:
              [5, 9, 13]:RepeatedConditionals tests switch at least 3 times (RepeatedConditional)

            If you get this warning then you are probably not using the right abstraction or even more probable, missing an additional abstraction.

            Cinstance tests 'others.empty?' at least 3 times
            Open

                  errors.add(:plan_id, 'is already bought') unless others.empty?
                end
              end
            
              def application_id_is_unique
            Severity: Minor
            Found in app/models/cinstance.rb by reek

            Repeated Conditional is a special case of Simulated Polymorphism. Basically it means you are checking the same value throughout a single class and take decisions based on this.

            Example

            Given

            class RepeatedConditionals
              attr_accessor :switch
            
              def repeat_1
                puts "Repeat 1!" if switch
              end
            
              def repeat_2
                puts "Repeat 2!" if switch
              end
            
              def repeat_3
                puts "Repeat 3!" if switch
              end
            end

            Reek would emit the following warning:

            test.rb -- 4 warnings:
              [5, 9, 13]:RepeatedConditionals tests switch at least 3 times (RepeatedConditional)

            If you get this warning then you are probably not using the right abstraction or even more probable, missing an additional abstraction.

            Cinstance tests 'new_record?' at least 4 times
            Open

                  unless new_record?
                    xml.id_ id
                    xml.created_at created_at.xmlschema
                    xml.updated_at updated_at.xmlschema
                  end
            Severity: Minor
            Found in app/models/cinstance.rb by reek

            Repeated Conditional is a special case of Simulated Polymorphism. Basically it means you are checking the same value throughout a single class and take decisions based on this.

            Example

            Given

            class RepeatedConditionals
              attr_accessor :switch
            
              def repeat_1
                puts "Repeat 1!" if switch
              end
            
              def repeat_2
                puts "Repeat 2!" if switch
              end
            
              def repeat_3
                puts "Repeat 3!" if switch
              end
            end

            Reek would emit the following warning:

            test.rb -- 4 warnings:
              [5, 9, 13]:RepeatedConditionals tests switch at least 3 times (RepeatedConditional)

            If you get this warning then you are probably not using the right abstraction or even more probable, missing an additional abstraction.

            Severity
            Category
            Status
            Source
            Language