TrestleAdmin/trestle

View on GitHub

Showing 35 of 62 total issues

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

        def initialize(builder, template, name, value=nil, options={}, &block)
Severity: Minor
Found in lib/trestle/form/fields/static_field.rb - About 45 mins to fix

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

        def tab(name, options={})
          tabs[name] = tab = Tab.new(name, options)
    
          content_tag(:div, id: tab.id(("modal" if dialog_request?)), class: ["tab-pane", ('active' if name == tabs.keys.first)], role: "tabpanel") do
            if block_given?
    Severity: Minor
    Found in app/helpers/trestle/tab_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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def create
              if save_instance
                respond_to do |format|
                  format.html do
                    flash[:message] = flash_message("create.success", title: "Success!", message: "The %{lowercase_model_name} was successfully created.")
    Severity: Minor
    Found in app/controllers/concerns/trestle/resource/controller/actions.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

          ruby2_keywords def method_missing(name, *args, &block)
            target = @form.respond_to?(name) ? @form : @template
    
            if block_given? && !RAW_BLOCK_HELPERS.include?(name)
              result = target.send(name, *args) do |*blockargs|
    Severity: Minor
    Found in lib/trestle/form/renderer.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def initialize(builder, template, name, options={}, &block)
    Severity: Minor
    Found in lib/trestle/form/field.rb - About 35 mins to fix

      Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def initialize(builder, template, name, options={}, &block)
      Severity: Minor
      Found in sandbox/app/fields/custom_field.rb - About 35 mins to fix

        Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                def initialize(builder, template, name=nil, options={}, &block)
        Severity: Minor
        Found in lib/trestle/form/fields/form_group.rb - About 35 mins to fix

          Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def initialize(template, label, instance_or_url={}, options={}, &block)
          Severity: Minor
          Found in lib/trestle/toolbar/item.rb - About 35 mins to fix

            Method col has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def col(columns=nil, breakpoints={})
                  if columns.is_a?(Hash)
                    breakpoints = columns
                    columns = breakpoints.delete("xs") || breakpoints.delete(:xs)
                  end
            Severity: Minor
            Found in app/helpers/trestle/grid_helper.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

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

                    def item(name, path=nil, options={})
                      if path.is_a?(Hash)
                        options = path
                        path = nil
                      end
            Severity: Minor
            Found in lib/trestle/navigation/block.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 default_wrapper_class has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def default_wrapper_class
                      if custom?
                        [
                          "custom-control",
                          "custom-radio",
            Severity: Minor
            Found in lib/trestle/form/fields/radio_button_helpers.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 apply_sorting has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def apply_sorting(collection, params)
                    return collection unless params[:sort]
            
                    field = params[:sort].to_sym
                    order = params[:order].to_s.downcase == "desc" ? :desc : :asc
            Severity: Minor
            Found in lib/trestle/resource/collection.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 fetch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def fetch(name)
                  name = name.to_sym
            
                  options.fetch(name) {
                    if defaults.key?(name)
            Severity: Minor
            Found in lib/trestle/configurable.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 header_text has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def header_text
                      if header = options[:header]
                        if header.respond_to?(:call)
                          @template.instance_exec(&header)
                        else
            Severity: Minor
            Found in lib/trestle/table/column.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 merge! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def merge!(other, &block)
                  super(other || {}) do |key, v1, v2|
                    if v1.is_a?(Hash) && v2.is_a?(Hash)
                      v1.merge(v2, &block)
                    elsif v1.is_a?(Array)
            Severity: Minor
            Found in lib/trestle/options.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