screenconcept/qbrick

View on GitHub

Showing 3 of 5 total issues

Class Page has 36 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Page < ActiveRecord::Base
    include ::RailsSettings::Extend
    include Qbrick::Engine.routes.url_helpers
    include Qbrick::Orderable
    include Qbrick::Translatable
Severity: Minor
Found in app/models/qbrick/page.rb - About 4 hrs to fix

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

          def model_attribute_field(resource, column_name, f)
            if resource.class.respond_to?(:uploaders) && resource.class.uploaders.keys.include?(column_name.to_sym)
              f.input column_name, as: :file
            elsif association_class(resource, column_name) == Qbrick::Page
              route_input f, column_name, page_routes
    Severity: Minor
    Found in app/helpers/qbrick/cms/admin_helper.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 all_object_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def all_object_hash(starting_with = nil)
            vars = thing_scoped.ordered
            vars = vars.where "var LIKE '#{starting_with}%'" if starting_with
    
            Hash[vars.map { |record| [record.var, record] }].with_indifferent_access.tap do |result|
    Severity: Minor
    Found in app/models/qbrick/settings.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