bestmike007/appbase

View on GitHub

Showing 9 of 9 total issues

Method add_query_stub has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def add_query_stub(model)
      m = model.name
      self.class_eval %-
        def query_#{AppBase.underscore m}
          query = #{m}.accessible_by(current_user)
Severity: Minor
Found in lib/appbase/controllers/app_base_controller.rb - About 1 hr to fix

    Method crud_allow has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def crud_allow(crud, criteria=:mine, &block)
            validate_crud crud
            
            if criteria == :mine
              allow_mine crud
    Severity: Minor
    Found in lib/appbase/model_concern.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 symbol_array_manipulate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def symbol_array_manipulate(op, source, options)
            raise InvalidUsage if op != :only && op != :except
            if options.has_key? op
              operands = options[op]
              operands = [operands] if operands.instance_of?(String) || operands.instance_of?(Symbol)
    Severity: Minor
    Found in lib/appbase/model_concern.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 init_parameters has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def init_parameters
            parameters = @bound_method.parameters
            pre_init_parameters(parameters)
            
            need_params = false
    Severity: Minor
    Found in lib/appbase/controllers/app_base_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 init has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

          def init
            init_parameters do |parameters, need_params|
              @requires = parameters.map{|p|":#{p[1]}"}
              @parameters = @auth ? ['current_user'] : []
              @requires.each { |p| @parameters << "params[#{p}]" }
    Severity: Minor
    Found in lib/appbase/controllers/app_base_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_usage has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def show_usage(crud)
            raise %-
              allow_#{crud} usage:
                allow_#{crud} :mine
                allow_#{crud} :#{ crud == :query ? 'within' : 'if' } => :a_singleton_method
    Severity: Minor
    Found in lib/appbase/model_concern.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 allow_criteria_with_block has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def allow_criteria_with_block(crud, block)
            show_usage(crud) if crud == :query && block.parameters.count != 1
            show_usage(crud) if crud != :query && block.parameters.count != 2
            model_inject crud == :query ? :accessible_by : "allow_#{crud}", &block
          end
    Severity: Minor
    Found in lib/appbase/model_concern.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 register_rpc has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def register_rpc(model, method_name, options={})
              rpc_registry_item = {
                model: (model.instance_of?(String) || model.instance_of?(Symbol)) ? Object.const_get(model.to_sym) : model,
                method: method_name.to_sym,
                auth: options.has_key?(:auth) ? options[:auth] : true
    Severity: Minor
    Found in lib/appbase/registry.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 each_crud has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

            def each_crud(*models, &block)
              models = models.flatten.map { |model| (model.instance_of?(Symbol) || model.instance_of?(String)) ? Object.const_get(model) : model }
              @crud_permissions.each do |r|
                block.call r[:model], r[:crud] if models.index(r[:model])
              end
    Severity: Minor
    Found in lib/appbase/registry.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