TrestleAdmin/trestle

View on GitHub

Showing 38 of 69 total issues

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

    def admin_url_for(instance=nil, admin: nil, action: nil, raise: false, **params)
      target = lookup_admin_from_options(
        instance: instance,
        admin: admin,
        fallback: self&.admin,
Severity: Minor
Found in app/helpers/trestle/url_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 lookup_admin_from_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def lookup_admin_from_options(instance: nil, admin: nil, fallback: nil, raise: true)
      if admin
        result = Trestle.lookup(admin)
      elsif instance
        result = Trestle.lookup_model(instance.class) || fallback
Severity: Minor
Found in app/helpers/trestle/url_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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def update
          if update_instance
            respond_to do |format|
              flash[:message] = flash_message("update.success", title: "Success!", message: "The %{lowercase_model_name} was successfully updated.")

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

    def tab(name, **options)
      tabs[name] = tab = Tab.new(name, **options)

      tag.div(id: tab.id(("modal" if modal_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 page_entries_info has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def page_entries_info(collection, options = {})
      entry_name = options[:entry_name] || "entry"
      entry_name = entry_name.pluralize unless collection.total_count == 1

      if collection.total_pages < 2
Severity: Minor
Found in app/helpers/trestle/pagination_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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def initialize(template, label, instance_or_url=nil, **options, &block)
Severity: Minor
Found in lib/trestle/toolbar/item.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(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, options={}, &block)
        Severity: Minor
        Found in lib/trestle/form/field.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 redirect_to_return_location has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def redirect_to_return_location(action, instance, status: :found, default: nil, &block)
                    fallback_location = block_given? ? block : default
          
                    if admin.return_locations[action] && !modal_request?
                      location = instance_exec(instance, &admin.return_locations[action])
          Severity: Minor
          Found in app/controllers/concerns/trestle/resource/controller/redirection.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 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 hue_to_rgb has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.hue_to_rgb(p, q, t)
                t += 1 if t < 0
                t -= 1 if t > 1
          
                if t < 1 / 6.0
          Severity: Minor
          Found in lib/trestle/color.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

          Function _rgbToHsl has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            _rgbToHsl (r, g, b) {
              r /= 255
              g /= 255
              b /= 255
          
          

          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

          Function follow has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            follow (e) {
              if (this.ignoreElement(e.target) || !this.url) {
                return
              }
          
          
          Severity: Minor
          Found in frontend/js/controllers/follow_url_controller.js - 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 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

          Severity
          Category
          Status
          Source
          Language