Showing 86 of 92 total issues

File base_controller.rb has 477 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require_dependency "avo/application_controller"

module Avo
  class BaseController < ApplicationController
    include Avo::Concerns::FiltersSessionHandler
Severity: Minor
Found in app/controllers/avo/base_controller.rb - About 7 hrs to fix

    Class BaseController has 50 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class BaseController < ApplicationController
        include Avo::Concerns::FiltersSessionHandler
    
        before_action :set_resource_name
        before_action :set_resource
    Severity: Minor
    Found in app/controllers/avo/base_controller.rb - About 7 hrs to fix

      Class ResourceGenerator has 40 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class ResourceGenerator < NamedBaseGenerator
            include Concerns::ParentController
            include Concerns::OverrideController
      
            source_root File.expand_path("templates", __dir__)
      Severity: Minor
      Found in lib/generators/avo/resource_generator.rb - About 5 hrs to fix

        Method visible_items has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
        Open

              def visible_items
                items
                  .map do |item|
                    hydrate_item item
        
        
        Severity: Minor
        Found in lib/avo/concerns/has_items.rb - About 4 hrs 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 eject_component has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

                def eject_component(component_to_eject = options[:component], confirmation: true)
                  # Underscore the component name
                  # Example: Avo::Views::ResourceIndexComponent => avo/views/resource_index_component
                  component = component_to_eject.underscore
        
        
        Severity: Minor
        Found in lib/generators/avo/eject_generator.rb - About 4 hrs 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

        Class AssociationsController has 32 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class AssociationsController < BaseController
            before_action :set_record, only: [:show, :index, :new, :create, :destroy]
            before_action :set_related_resource_name
            before_action :set_related_resource, only: [:show, :index, :new, :create, :destroy]
            before_action :set_related_authorization
        Severity: Minor
        Found in app/controllers/avo/associations_controller.rb - About 4 hrs to fix

          File resource_generator.rb has 329 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          require_relative "named_base_generator"
          require_relative "concerns/parent_controller"
          require_relative "concerns/override_controller"
          
          module Generators
          Severity: Minor
          Found in lib/generators/avo/resource_generator.rb - About 3 hrs to fix

            Class ResourceComponent has 27 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class Avo::ResourceComponent < Avo::BaseComponent
              include Avo::Concerns::ChecksAssocAuthorization
              include Avo::Concerns::RequestMethods
            
              attr_reader :fields_by_panel
            Severity: Minor
            Found in app/components/avo/resource_component.rb - About 3 hrs to fix

              Method only_fields has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                    def only_fields(only_root: false)
                      fields = []
              
                      items.each do |item|
                        next if item.nil?
              Severity: Minor
              Found in lib/avo/concerns/has_items.rb - About 3 hrs 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 unwrap has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                def unwrap(i, level = 0, view: :show)
                  result = []
              
                  i.items.each do |item|
                    label = ""
              Severity: Minor
              Found in lib/avo/item_grapher.rb - About 3 hrs 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

              Class ResourceIndexComponent has 26 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
                include Avo::ResourcesHelper
                include Avo::ApplicationHelper
              
                prop :resource
              Severity: Minor
              Found in app/components/avo/views/resource_index_component.rb - About 3 hrs to fix

                Function addSource has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  addSource(resourceName, data) {
                    const that = this
                
                    return {
                      sourceId: resourceName,
                Severity: Major
                Found in app/javascript/js/controllers/search_controller.js - About 2 hrs to fix

                  Class Configuration has 25 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                    class Configuration
                      include ResourceConfiguration
                  
                      attr_writer :app_name
                      attr_writer :branding
                  Severity: Minor
                  Found in lib/avo/configuration.rb - About 2 hrs to fix

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

                      enableResourceActions() {
                        this.actionLinks.forEach((link) => {
                          link.classList.add(link.dataset.enabledClasses)
                          link.classList.remove(link.dataset.disabledClasses)
                          link.setAttribute('data-href', link.getAttribute('href'))
                    Severity: Major
                    Found in app/javascript/js/controllers/item_selector_controller.js and 1 other location - About 2 hrs to fix
                    app/javascript/js/controllers/item_selector_controller.js on lines 75..82

                    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 110.

                    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

                      disableResourceActions() {
                        this.actionLinks.forEach((link) => {
                          link.classList.remove(link.dataset.enabledClasses)
                          link.classList.add(link.dataset.disabledClasses)
                          link.setAttribute('href', link.getAttribute('data-href'))
                    Severity: Major
                    Found in app/javascript/js/controllers/item_selector_controller.js and 1 other location - About 2 hrs to fix
                    app/javascript/js/controllers/item_selector_controller.js on lines 66..73

                    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 110.

                    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 create_files has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            def create_files
                              unless tailwindcss_installed?
                                say "Installing Tailwindcss"
                                system "./bin/bundle add tailwindcss-rails"
                                system "./bin/rails tailwindcss:install"
                    Severity: Major
                    Found in lib/generators/avo/tailwindcss/install_generator.rb - About 2 hrs to fix

                      Method initialize_views has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                      Open

                            def initialize_views
                              # Set defaults
                              @show_on_index = @show_on_index.nil? ? true : @show_on_index
                              @show_on_show = @show_on_show.nil? ? true : @show_on_show
                              @show_on_new = @show_on_new.nil? ? true : @show_on_new
                      Severity: Minor
                      Found in lib/avo/concerns/visible_in_different_views.rb - About 2 hrs 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 62 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          def initialize
                            @root_path = "/avo"
                            @app_name = ::Rails.application.class.to_s.split("::").first.underscore.humanize(keep_id_suffix: true)
                            @timezone = "UTC"
                            @per_page = 24
                      Severity: Major
                      Found in lib/avo/configuration.rb - About 2 hrs to fix

                        Method initialize has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                        Open

                              def initialize(id, **args, &block)
                                super(id, **args, &block)
                        
                                hide_on :index
                        
                        
                        Severity: Minor
                        Found in lib/avo/fields/key_value_field.rb - About 2 hrs 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 eject_partial has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                                def eject_partial
                                  if options[:partial].starts_with?(":")
                                    template_id = path_to_sym options[:partial]
                                    template_path = TEMPLATES[template_id]
                        
                        
                        Severity: Minor
                        Found in lib/generators/avo/eject_generator.rb - About 2 hrs 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