I-de-ya/ideyabox

View on GitHub
lib/generators/ideyabox/images_scaffold/images_scaffold_generator.rb

Summary

Maintainability
C
1 day
Test Coverage

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

    class ImagesScaffoldGenerator < ::Rails::Generators::Base
      source_root File.expand_path('../templates', __FILE__)
      argument :controller_path,    :type => :string
      argument :model_name,         :type => :string, :required => false
      argument :layout,             :type => :string, :default => "application",
Severity: Minor
Found in lib/generators/ideyabox/images_scaffold/images_scaffold_generator.rb - About 2 hrs to fix

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

          def add_resource_route
            resources_string = "\n    resources :#{plural_resource_name} do\n"
            sort_string = "      post \"sort\", :on => :collection\n"
            toggleshow_string = "      get \"toggleshow\", :on => :member\n"
            
    lib/generators/ideyabox/crop/crop_generator.rb on lines 155..175

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

    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

    Identical blocks of code found in 5 locations. Consider refactoring.
    Open

          def columns
            begin
              excluded_column_names = %w[id created_at updated_at]
              @model_name.constantize.columns.reject{|c| excluded_column_names.include?(c.name) || c.name.index("_id") }.sort{|a, b| sort_priority(a.name) <=> sort_priority(b.name)}.collect{|c| ::Rails::Generators::GeneratedAttribute.new(c.name, c.type)}
            rescue NoMethodError
    lib/generators/ideyabox/crop/crop_generator.rb on lines 113..118
    lib/generators/ideyabox/many_to_many/many_to_many_generator.rb on lines 128..133
    lib/generators/ideyabox/scaffold/scaffold_generator.rb on lines 78..83
    lib/generators/ideyabox/tree/tree_generator.rb on lines 115..120

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

    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

    Identical blocks of code found in 3 locations. Consider refactoring.
    Open

          def add_to_locales
            locales = [:ru, :en]
            
            attributes = column_names.collect {|column| "        #{column}: \"#{column}\"\n"}
    
    
    lib/generators/ideyabox/crop/crop_generator.rb on lines 177..187
    lib/generators/ideyabox/tree/tree_generator.rb on lines 192..202

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

    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

    Identical blocks of code found in 5 locations. Consider refactoring.
    Open

          def extract_modules(name)
            modules = name.include?('/') ? name.split('/') : name.split('::')
            name    = modules.pop
            path    = modules.map { |m| m.underscore }
            file_path = (path + [name.underscore]).join('/')
    lib/generators/ideyabox/crop/crop_generator.rb on lines 126..132
    lib/generators/ideyabox/many_to_many/many_to_many_generator.rb on lines 162..168
    lib/generators/ideyabox/scaffold/scaffold_generator.rb on lines 91..97
    lib/generators/ideyabox/tree/tree_generator.rb on lines 128..134

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

    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

    Identical blocks of code found in 4 locations. Consider refactoring.
    Open

          def initialize_views_variables
            @base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(controller_path)
            @controller_routing_path = @controller_file_path.gsub(/\//, '_')
            @model_name = @controller_class_nesting + "::#{@base_name.singularize.camelize}" unless @model_name
            @model_name = @model_name.camelize
    lib/generators/ideyabox/crop/crop_generator.rb on lines 64..68
    lib/generators/ideyabox/scaffold/scaffold_generator.rb on lines 37..41
    lib/generators/ideyabox/tree/tree_generator.rb on lines 74..78

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

    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

    There are no issues that match your filters.

    Category
    Status