marcomd/Active_Leonardo

View on GitHub

Showing 13 of 18 total issues

Method scaffold has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

      def scaffold
        # puts "args #{self.args}"
        # puts "options #{self.options}"
         puts "behavior #{self.behavior}"
        # puts "shell #{self.shell}"
Severity: Minor
Found in lib/generators/leosca/massive_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

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

  def item(options={})
    #:search     => {:id => 3}
    #:get        => :name
    options = {
      :search   => nil,
Severity: Minor
Found in lib/generators/leolay/templates/lib/upd_array.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 setup_authentication has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def setup_authentication
    file = "app/models/#{options[:auth_class].downcase}.rb"
    #puts "File #{file} #{File.exists?(file) ? "" : "does not"} exists!"
    return unless options.authentication? and File.exists?(file)

Severity: Minor
Found in lib/generators/leolay/leolay_generator.rb - About 1 hr to fix

    Method create_users_for_development has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def create_users_for_development
        return unless options.authentication?
        file = "db/seeds.rb"
        # Remove devise default user
        gsub_file file, /User\.create!\(.+\)/, "" if File.exists?(file)
    Severity: Minor
    Found in lib/generators/leolay/leolay_generator.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 setup_application has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def setup_application
    
        application do
          <<-FILE.gsub(/^      /, '')
          config.generators do |g|
    Severity: Minor
    Found in lib/generators/leolay/leolay_generator.rb - About 1 hr to fix

      Method generate_layout has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

        def generate_layout
          template "styles/#{style_name}/stylesheets/app/stylesheet.scss.erb",          "app/assets/stylesheets/#{style_name}.scss.erb"
          template "styles/#{style_name}/stylesheets/app/custom_active_admin.scss.erb", "app/assets/stylesheets/custom_active_admin.scss.erb"
          template "styles/#{style_name}/stylesheets/app/_production.scss",             "app/assets/stylesheets/_production.scss"
      
      
      Severity: Minor
      Found in lib/generators/leolay/leolay_generator.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 scaffold has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def scaffold
              # puts "args #{self.args}"
              # puts "options #{self.options}"
               puts "behavior #{self.behavior}"
              # puts "shell #{self.shell}"
      Severity: Minor
      Found in lib/generators/leosca/massive_generator.rb - About 1 hr to fix

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

          def setup_rspec
            file = "spec/spec_helper.rb"
            return unless File.exists?(file) && options.rspec?
            inject_into_file file, :after => "require 'rspec/rails'" do
            <<-FILE.gsub(/^    /, '')
        Severity: Minor
        Found in lib/generators/leolay/leolay_generator.rb - About 1 hr to fix

          Method setup_activeadmin has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def setup_activeadmin
              return unless options.activeadmin? and activeadmin?
              template "config/initializers/activeadmin_leonardo.rb", "config/initializers/activeadmin_leonardo.rb"
              #copy_file "config/initializers/activeadmin_cancan.rb", "config/initializers/activeadmin_cancan.rb" if options.authorization?
              #template "app/admin/users.rb", "app/admin/#{options[:auth_class].downcase.pluralize}.rb"
          Severity: Minor
          Found in lib/generators/leolay/leolay_generator.rb - About 1 hr to fix

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

                  def generate line
                    regexp_rails_g = 'rails [dg][a-z]*\s'
                    line.strip!
                    unless line.empty? or line[0..0]=="#"
                      if /#{regexp_rails_g}/i === line
            Severity: Minor
            Found in lib/generators/leosca/massive_generator.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 invoke_active_admin has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def invoke_active_admin
                    return unless activeadmin? && options[:activeadmin]
            
                    invoke "active_admin:resource", [singular_table_name]
                    file = "app/admin/#{singular_table_name}.rb"
            Severity: Minor
            Found in lib/generators/rails/leosca_controller/leosca_controller_generator.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 get_attr_to_check has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def get_attr_to_check(view=:list)
                    case view
                      when :something
                      else
                        attributes.each{|a| case a.type when :string, :text then return a.name end}
            Severity: Minor
            Found in lib/generators/active_leonardo.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 add_seeds_db has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def add_seeds_db
                    return unless options.seeds? and options[:seeds_elements].to_i > 0
                    file = "db/seeds.rb"
                    append_file file do
                      items = []
            Severity: Minor
            Found in lib/generators/rails/leosca_controller/leosca_controller_generator.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

            Severity
            Category
            Status
            Source
            Language