TrestleAdmin/trestle

View on GitHub

Showing 47 of 62 total issues

Method default_wrapper_class has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

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

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

      def content_columns
        admin.default_table_attributes.map.with_index do |attribute, index|
          case attribute.type
          when :association
            Column.new(attribute.association_name, sort: false)
Severity: Minor
Found in lib/trestle/table/automatic.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 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def show
          if admin.singular? && instance.nil?
            respond_to do |format|
              format.html { redirect_to action: :new }
              format.json { head :not_found }
Severity: Minor
Found in app/controllers/concerns/trestle/resource/controller/actions.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 edit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def edit
          if admin.singular? && instance.nil?
            respond_to do |format|
              format.html { redirect_to action: :new }
              format.json { head :not_found }
Severity: Minor
Found in app/controllers/concerns/trestle/resource/controller/actions.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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        def show
          if admin.singular? && instance.nil?
            respond_to do |format|
              format.html { redirect_to action: :new }
              format.json { head :not_found }
Severity: Minor
Found in app/controllers/concerns/trestle/resource/controller/actions.rb and 1 other location - About 55 mins to fix
app/controllers/concerns/trestle/resource/controller/actions.rb on lines 65..80

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 45.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        def edit
          if admin.singular? && instance.nil?
            respond_to do |format|
              format.html { redirect_to action: :new }
              format.json { head :not_found }
Severity: Minor
Found in app/controllers/concerns/trestle/resource/controller/actions.rb and 1 other location - About 55 mins to fix
app/controllers/concerns/trestle/resource/controller/actions.rb on lines 47..62

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 45.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    def admin_url_for(instance, options={})
      admin = Trestle.lookup(options.delete(:admin)) if options.key?(:admin)
      admin ||= admin_for(instance)
      return unless 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 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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def update
          if update_instance
            respond_to do |format|
              format.html do
                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 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                respond_to do |format|
                  format.html do
                    flash.now[:error] = flash_message("update.failure", title: "Warning!", message: "Please correct the errors below.")
                    render "show", status: :unprocessable_entity
                  end
    Severity: Minor
    Found in app/controllers/concerns/trestle/resource/controller/actions.rb and 1 other location - About 40 mins to fix
    app/controllers/concerns/trestle/resource/controller/actions.rb on lines 35..43

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 38.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                respond_to do |format|
                  format.html do
                    flash.now[:error] = flash_message("create.failure", title: "Warning!", message: "Please correct the errors below.")
                    render "new", status: :unprocessable_entity
                  end
    Severity: Minor
    Found in app/controllers/concerns/trestle/resource/controller/actions.rb and 1 other location - About 40 mins to fix
    app/controllers/concerns/trestle/resource/controller/actions.rb on lines 95..103

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 38.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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
            Severity
            Category
            Status
            Source
            Language