marcomd/Active_Leonardo

View on GitHub
lib/generators/leolay/leolay_generator.rb

Summary

Maintainability
C
1 day
Test Coverage

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

          There are no issues that match your filters.

          Category
          Status