MiraitSystems/enju_trunk

View on GitHub
app/controllers/series_statements_controller.rb

Summary

Maintainability
D
1 day
Test Coverage

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

  def edit
    @series_statement.work = @work if @work
    @creators = @series_statement.root_manifestation.try(:creates).present? ? @series_statement.root_manifestation.creates.order(:position) : [{}] unless @creators
    @contributors = @series_statement.root_manifestation.try(:realizes).present? ? @series_statement.root_manifestation.realizes.order(:position) : [{}] unless @contributors
    @publishers = @series_statement.root_manifestation.try(:produces).present? ? @series_statement.root_manifestation.produces.order(:position) : [{}] unless @publishers
Severity: Minor
Found in app/controllers/series_statements_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 set_root_manifestation_instance_vals has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def set_root_manifestation_instance_vals(root_manifestation)
    @creators = root_manifestation.try(:creates).present? ? root_manifestation.creates.order(:position) : [{}] unless @creators
    @contributors = root_manifestation.try(:realizes).present? ? root_manifestation.realizes.order(:position) : [{}] unless @contributors
    @publishers = root_manifestation.try(:produces).present? ? root_manifestation.produces.order(:position) : [{}] unless @publishers
    @subjects = root_manifestation.try(:subjects).present? ? root_manifestation.subjects.order(:position) : [{}] unless @subjects
Severity: Minor
Found in app/controllers/series_statements_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 index has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    search = Sunspot.new_search(SeriesStatement)
    query = params[:query].to_s.strip
    page = params[:page] || 1
    unless query.blank?
Severity: Minor
Found in app/controllers/series_statements_controller.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 prepare_options has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def prepare_options
    @subject_types = SubjectType.all
    @carrier_types = CarrierType.all
    @sub_carrier_types = SubCarrierType.all
    @manifestation_types = ManifestationType.all#ManifestationType.series
Severity: Minor
Found in app/controllers/series_statements_controller.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 prepare_options has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def prepare_options
    @subject_types = SubjectType.all
    @carrier_types = CarrierType.all
    @sub_carrier_types = SubCarrierType.all
    @manifestation_types = ManifestationType.all#ManifestationType.series
Severity: Minor
Found in app/controllers/series_statements_controller.rb - About 1 hr to fix

    Method update has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def update
        SeriesStatement.transaction do
          if params[:move]
            move_position(@series_statement, params[:move])
            return
    Severity: Minor
    Found in app/controllers/series_statements_controller.rb - About 1 hr to fix

      Method index has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def index
          search = Sunspot.new_search(SeriesStatement)
          query = params[:query].to_s.strip
          page = params[:page] || 1
          unless query.blank?
      Severity: Minor
      Found in app/controllers/series_statements_controller.rb - About 1 hr to fix

        Method update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def update
            SeriesStatement.transaction do
              if params[:move]
                move_position(@series_statement, params[:move])
                return
        Severity: Minor
        Found in app/controllers/series_statements_controller.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 create_classification_values has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def create_classification_values(add_classifications)
            return nil if add_classifications.blank?
            classifications = []
            add_classifications.each do |add_classification|
              next if add_classification[:classification_id].blank?
        Severity: Minor
        Found in app/controllers/series_statements_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

          rescue Exception => e
            logger.error "Failed to create: #{e}"
            prepare_options
            respond_to do |format|
              format.html { render :action => "new" }
        Severity: Minor
        Found in app/controllers/series_statements_controller.rb and 1 other location - About 30 mins to fix
        app/controllers/series_statements_controller.rb on lines 154..161

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

        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

          rescue Exception => e
            logger.error "Failed to update: #{e}"
            prepare_options
            respond_to do |format|
              format.html { render :action => "edit" }
        Severity: Minor
        Found in app/controllers/series_statements_controller.rb and 1 other location - About 30 mins to fix
        app/controllers/series_statements_controller.rb on lines 120..127

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

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

          def get_classification_values(manifestation)
            classifications = []
            manifestation_has_classifications = manifestation.manifestation_has_classifications.order(:position)
            if manifestation_has_classifications.present?
              manifestation_has_classifications.each do |manifestation_has_classification|
        Severity: Minor
        Found in app/controllers/series_statements_controller.rb and 1 other location - About 25 mins to fix
        app/controllers/manifestations_controller.rb on lines 2048..2059

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

        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