inossidabile/protector

View on GitHub

Showing 12 of 18 total issues

Method first_unmodifiable_field has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

        def first_unmodifiable_field(part, fields)
          return (fields.keys.first || '-') unless @access[part]

          diff = fields.keys - @access[part].keys
          return diff.first if diff.length > 0
Severity: Minor
Found in lib/protector/dsl.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

Method cannot has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

        def cannot(action, *fields)
          action = deprecate_actions(action)

          return @destroyable = false if action == :destroy

Severity: Minor
Found in lib/protector/dsl.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 protector_defend_graph has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def protector_defend_graph(relation, subject)
          return relation unless @opts[:eager_graph]

          @opts[:eager_graph][:reflections].each do |association, reflection|
            model = reflection[:cache][:class] if reflection[:cache].is_a?(Hash) && reflection[:cache][:class]
Severity: Minor
Found in lib/protector/adapters/sequel/dataset.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 can has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

        def can(action, *fields)
          action = deprecate_actions(action)

          return @destroyable = true if action == :destroy

Severity: Minor
Found in lib/protector/dsl.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        def initialize(adapter, model, fields, subject, entry, blocks)
Severity: Minor
Found in lib/protector/dsl.rb - About 45 mins to fix

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

            def protector_expand_inclusion_hash(inclusion, results=[], base=[], klass=@klass)
              inclusion.each do |key, value|
                model = klass.reflect_on_association(key.to_sym).klass
                value = [value] unless value.is_a?(Array)
                nest  = [key] + base
    Severity: Minor
    Found in lib/protector/adapters/active_record/relation.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 valid? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            def valid?(*args)
              if protector_subject?
                state  = Protector.insecurely{ super(*args) }
                method = new_record? ? :first_uncreatable_field : :first_unupdatable_field
                field  = protector_meta.send(method, protector_changed)
    Severity: Minor
    Found in lib/protector/adapters/active_record/validations.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 k if !x.nil? && x != v
    Severity: Major
    Found in lib/protector/dsl.rb - About 30 mins to fix

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

                def [](name)
                  # rubocop:disable ParenthesesAroundCondition
                  if (
                    !protector_subject? ||
                    name == self.class.primary_key ||
      Severity: Minor
      Found in lib/protector/adapters/active_record/base.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

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

              def protector_expand_inclusion(inclusion, results=[], base=[], klass=@klass)
                if inclusion.is_a?(Hash)
                  protector_expand_inclusion_hash(inclusion, results, base, klass)
                else
                  Array(inclusion).each do |i|
      Severity: Minor
      Found in lib/protector/adapters/active_record/relation.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

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

              def exec_queries_with_protector(*args)
                return @records if loaded?
                return exec_queries_without_protector unless protector_subject?
      
                subject  = protector_subject
      Severity: Minor
      Found in lib/protector/adapters/active_record/relation.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

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

        def run_state(state, color)
          data = {}
          prof = @profiling
      
          print_block "Protector #{state.send color}" do
      Severity: Minor
      Found in perf/perf_helpers/boot.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