varvet/godmin

View on GitHub

Showing 14 of 116 total issues

File template.rb has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "active_support/all"

def install_standalone
  set_ruby_version

Severity: Minor
Found in template.rb - About 2 hrs to fix

    Function BatchActions has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    Godmin.BatchActions = (function() {
      var $container;
      var $selectAll;
      var $selectNone;
    
    
    Severity: Major
    Found in app/assets/javascripts/godmin/batch-actions.js - About 2 hrs to fix

      Method column_header has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

            def column_header(attribute)
              if @resource_service.orderable_column?(attribute.to_s)
                direction =
                  if params[:order].present?
                    if params[:order].match(/\A#{attribute.to_s}_(asc|desc)\z/)
      Severity: Minor
      Found in lib/godmin/helpers/tables.rb - About 1 hr 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 modify_article_service has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def modify_article_service(namespace = nil)
        article_service =
          if namespace
            "admin/app/services/admin/article_service.rb"
          else
      Severity: Minor
      Found in template.rb - About 1 hr to fix

        Function Datetimepickers has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Godmin.Datetimepickers = (function() {
          function initialize() {
            initializeEvents();
            initializeState();
          }
        Severity: Minor
        Found in app/assets/javascripts/godmin/datetimepickers.js - About 1 hr to fix

          Method install_engine has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          def install_engine
            set_ruby_version
          
            run_ruby_script("bin/rails plugin new admin --mountable")
          
          
          Severity: Minor
          Found in template.rb - About 1 hr to fix

            Function Navigation has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            Godmin.Navigation = (function() {
              function initialize() {
                initializeEvents();
                initializeState();
              }
            Severity: Minor
            Found in app/assets/javascripts/godmin/navigation.js - About 1 hr to fix

              Method filter_select has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def filter_select(name, options, html_options)
                      unless options[:collection].is_a? Proc
                        raise "A collection proc must be specified for select filters"
                      end
              
              
              Severity: Minor
              Found in lib/godmin/helpers/filters.rb - About 1 hr to fix

                Method generate_models has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                def generate_models
                  generate(:model, "author name:string")
                  generate(:model, "article title:string body:text author:references published:boolean published_at:datetime")
                
                  gsub_file Dir.glob("db/migrate/*_create_articles.rb").first, "t.boolean :published", "t.boolean :published, default: false"
                Severity: Minor
                Found in template.rb - About 1 hr to fix

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

                        def navbar_item(resource, url = resource, show: nil, icon: nil, **options)
                          show ||= lambda do
                            resource.is_a?(String) ? true : policy(resource).index?
                          end
                  
                  
                  Severity: Minor
                  Found in lib/godmin/helpers/navigation.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

                  Function BatchActions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  Godmin.BatchActions = (function() {
                    var $container;
                    var $selectAll;
                    var $selectNone;
                  
                  
                  Severity: Minor
                  Found in app/assets/javascripts/godmin/batch-actions.js - 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 _find_all has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def _find_all(name, prefix, partial, details, key, locals)
                  Severity: Minor
                  Found in lib/godmin/resolver.rb - About 45 mins to fix

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

                          def column_value(resource, attribute)
                            partial_override "#{controller_path}/columns/#{attribute}", resource: resource do
                              column_value = resource.send(attribute)
                    
                              if column_value.is_a?(Date) || column_value.is_a?(Time)
                    Severity: Minor
                    Found in lib/godmin/helpers/tables.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 perform_batch_action has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def perform_batch_action
                              return unless params[:batch_action].present?
                    
                              set_resource_service
                              set_resource_class
                    Severity: Minor
                    Found in lib/godmin/resources/resource_controller/batch_actions.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