indentlabs/notebook

View on GitHub
app/controllers/basil_controller.rb

Summary

Maintainability
F
4 days
Test Coverage

File basil_controller.rb has 506 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class BasilController < ApplicationController
  before_action :authenticate_user!, except: [:complete_commission, :about, :stats, :jam, :queue_jam_job, :commission_info]

  before_action :require_admin_access, only: [:review], unless: -> { Rails.env.development? }

Severity: Major
Found in app/controllers/basil_controller.rb - About 1 day to fix

    Method content has 139 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def content
        # Fetch the content page from our already-queried cache of current user content
        @content_type = params[:content_type].humanize
        @content      = @current_user_content[@content_type].detect do |page|
          page.id == params[:id].to_i
    Severity: Major
    Found in app/controllers/basil_controller.rb - About 5 hrs to fix

      Method commission has 87 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def commission
          @generated_images_count  = current_user.basil_commissions.with_deleted.count
          if !current_user.on_premium_plan? && @generated_images_count > BasilService::FREE_IMAGE_LIMIT
            redirect_back fallback_location: basil_path, notice: "You've reached your free image limit. Please upgrade to generate more images."
            return
      Severity: Major
      Found in app/controllers/basil_controller.rb - About 3 hrs to fix

        Method stats has 73 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def stats
            @commissions = BasilCommission.all.with_deleted
        
            @queued = BasilCommission.where(completed_at: nil)
            @completed = BasilCommission.where.not(completed_at: nil).with_deleted
        Severity: Major
        Found in app/controllers/basil_controller.rb - About 2 hrs to fix

          Method page_stats has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def page_stats
              @page_type = params[:page_type]
              # TODO verify page_type is valid
          
              @commissions = BasilCommission.where(entity_type: @page_type)
          Severity: Major
          Found in app/controllers/basil_controller.rb - About 2 hrs to fix

            Method commission has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def commission
                @generated_images_count  = current_user.basil_commissions.with_deleted.count
                if !current_user.on_premium_plan? && @generated_images_count > BasilService::FREE_IMAGE_LIMIT
                  redirect_back fallback_location: basil_path, notice: "You've reached your free image limit. Please upgrade to generate more images."
                  return
            Severity: Minor
            Found in app/controllers/basil_controller.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 stats has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def stats
                @commissions = BasilCommission.all.with_deleted
            
                @queued = BasilCommission.where(completed_at: nil)
                @completed = BasilCommission.where.not(completed_at: nil).with_deleted
            Severity: Minor
            Found in app/controllers/basil_controller.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

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

                when 'Lore'
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Type')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Content', 'Genre')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Content', 'Tone')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Culture', 'Time period')
            Severity: Major
            Found in app/controllers/basil_controller.rb and 1 other location - About 1 hr to fix
            app/controllers/basil_controller.rb on lines 169..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 51.

            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

                when 'Sport'
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Description')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Setup', 'Play area')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Setup', 'Equipment')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Setup', 'Number of players')
            Severity: Major
            Found in app/controllers/basil_controller.rb and 1 other location - About 1 hr to fix
            app/controllers/basil_controller.rb on lines 135..142

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

            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 4 locations. Consider refactoring.
            Open

                @emoji_counts_all_time = @feedback_before_today.map do |score, count|
                  emoji = case score
                    when -2 then "Very Bad :'("
                    when -1 then "Bad :("
                    when  0 then "Meh :|"
            Severity: Major
            Found in app/controllers/basil_controller.rb and 3 other locations - About 50 mins to fix
            app/controllers/basil_controller.rb on lines 282..291
            app/controllers/basil_controller.rb on lines 366..375
            app/controllers/basil_controller.rb on lines 388..398

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

            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

                when 'Location'
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Name')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Type')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Description')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Geography', 'Area')
            Severity: Minor
            Found in app/controllers/basil_controller.rb and 1 other location - About 50 mins to fix
            app/controllers/basil_controller.rb on lines 76..81

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

            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

                when 'Continent'
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Description')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Geography', 'Area')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Geography', 'Shape')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Geography', 'Topography')
            Severity: Minor
            Found in app/controllers/basil_controller.rb and 1 other location - About 50 mins to fix
            app/controllers/basil_controller.rb on lines 50..55

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

            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 4 locations. Consider refactoring.
            Open

                @emoji_counts_today = @feedback_today.map do |score, count|
                  emoji = case score
                    when -2 then "Very Bad :'("
                    when -1 then "Bad :("
                    when  0 then "Meh :|"
            Severity: Major
            Found in app/controllers/basil_controller.rb and 3 other locations - About 50 mins to fix
            app/controllers/basil_controller.rb on lines 303..313
            app/controllers/basil_controller.rb on lines 366..375
            app/controllers/basil_controller.rb on lines 388..398

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

            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 4 locations. Consider refactoring.
            Open

                @emoji_counts_all_time = @feedback_before_today.map do |score, count|
                  emoji = case score
                    when -2 then "Very Bad :'("
                    when -1 then "Bad :("
                    when  0 then "Meh :|"
            Severity: Major
            Found in app/controllers/basil_controller.rb and 3 other locations - About 50 mins to fix
            app/controllers/basil_controller.rb on lines 282..291
            app/controllers/basil_controller.rb on lines 303..313
            app/controllers/basil_controller.rb on lines 366..375

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

            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 4 locations. Consider refactoring.
            Open

                @emoji_counts_today = @feedback_today.map do |score, count|
                  emoji = case score
                    when -2 then "Very Bad :'("
                    when -1 then "Bad :("
                    when  0 then "Meh :|"
            Severity: Major
            Found in app/controllers/basil_controller.rb and 3 other locations - About 50 mins to fix
            app/controllers/basil_controller.rb on lines 282..291
            app/controllers/basil_controller.rb on lines 303..313
            app/controllers/basil_controller.rb on lines 388..398

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

            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

                when 'Building'
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Name')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Type of building')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Description')
                  @relevant_fields.push *BasilService.include_all_fields_in_category(current_user, @content, ['Design'])
            Severity: Minor
            Found in app/controllers/basil_controller.rb and 1 other location - About 35 mins to fix
            app/controllers/basil_controller.rb on lines 144..150

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

            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

                when 'Magic'
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Name')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Type of magic')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Description')
                  @relevant_fields.push *BasilService.include_all_fields_in_category(current_user, @content, ['Appearance'])
            Severity: Minor
            Found in app/controllers/basil_controller.rb and 1 other location - About 35 mins to fix
            app/controllers/basil_controller.rb on lines 64..70

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

            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 3 locations. Consider refactoring.
            Open

                when 'School'
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Type of school')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Identity', 'Colors')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Description')
            Severity: Minor
            Found in app/controllers/basil_controller.rb and 2 other locations - About 20 mins to fix
            app/controllers/basil_controller.rb on lines 83..86
            app/controllers/basil_controller.rb on lines 185..188

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

            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 3 locations. Consider refactoring.
            Open

                when 'Tradition'
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Type of tradition')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Celebrations', 'Activities')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Celebrations', 'Symbolism')
            Severity: Minor
            Found in app/controllers/basil_controller.rb and 2 other locations - About 20 mins to fix
            app/controllers/basil_controller.rb on lines 83..86
            app/controllers/basil_controller.rb on lines 164..167

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

            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 3 locations. Consider refactoring.
            Open

                when 'Country'
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Overview', 'Description')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Geography', 'Area')
                  @relevant_fields.push BasilService.include_specific_field(current_user, @content, 'Geography', 'Climate')
            Severity: Minor
            Found in app/controllers/basil_controller.rb and 2 other locations - About 20 mins to fix
            app/controllers/basil_controller.rb on lines 164..167
            app/controllers/basil_controller.rb on lines 185..188

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

            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

                @average_score_per_style = BasilCommission.with_deleted
                                                          .where(style: active_styles)
                                                          .joins(:basil_feedbacks)
                                                          .group(:style)
                                                          .average(:score_adjustment)
            Severity: Minor
            Found in app/controllers/basil_controller.rb and 1 other location - About 15 mins to fix
            app/controllers/basil_controller.rb on lines 323..329

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

            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

                @total_score_per_style = BasilCommission.with_deleted
                                                        .where(style: active_styles)
                                                        .joins(:basil_feedbacks)
                                                        .group(:style)
                                                        .sum(:score_adjustment)
            Severity: Minor
            Found in app/controllers/basil_controller.rb and 1 other location - About 15 mins to fix
            app/controllers/basil_controller.rb on lines 331..337

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

            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