SysMO-DB/seek

View on GitHub
app/controllers/assays_controller.rb

Summary

Maintainability
D
2 days
Test Coverage

Method create has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    params[:assay_class_id] ||= AssayClass.for_type("experimental").id
    @assay        = Assay.new(params[:assay])

    organisms     = params[:assay_organism_ids] || []
Severity: Minor
Found in app/controllers/assays_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 update has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def update

    #FIXME: would be better to resolve the differences, rather than keep clearing and reading the assets and organisms
    #DOES resolve differences for assets now
    organisms             = params[:assay_organism_ids]||[]
Severity: Minor
Found in app/controllers/assays_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 new_object_based_on_existing_one has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def new_object_based_on_existing_one
    @existing_assay =  Assay.find(params[:id])
    @assay = @existing_assay.clone_with_associations
    params[:data_file_ids]=@existing_assay.data_file_masters.collect{|d|"#{d.id},None"}
    params[:related_publication_ids]= @existing_assay.related_publications.collect{|p| "#{p.id},None"}
Severity: Minor
Found in app/controllers/assays_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 update has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def update

    #FIXME: would be better to resolve the differences, rather than keep clearing and reading the assets and organisms
    #DOES resolve differences for assets now
    organisms             = params[:assay_organism_ids]||[]
Severity: Minor
Found in app/controllers/assays_controller.rb - About 1 hr to fix

    Method create has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def create
        params[:assay_class_id] ||= AssayClass.for_type("experimental").id
        @assay        = Assay.new(params[:assay])
    
        organisms     = params[:assay_organism_ids] || []
    Severity: Minor
    Found in app/controllers/assays_controller.rb - About 1 hr to fix

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

        def new
          @assay=Assay.new
          @assay.create_from_asset = params[:create_from_asset]
          study = Study.find(params[:study_id]) if params[:study_id]
          @assay.study = study if params[:study_id] if study.try :can_edit?
      Severity: Minor
      Found in app/controllers/assays_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 new_object_based_on_existing_one has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def new_object_based_on_existing_one
          @existing_assay =  Assay.find(params[:id])
          @assay = @existing_assay.clone_with_associations
          params[:data_file_ids]=@existing_assay.data_file_masters.collect{|d|"#{d.id},None"}
          params[:related_publication_ids]= @existing_assay.related_publications.collect{|p| "#{p.id},None"}
      Severity: Minor
      Found in app/controllers/assays_controller.rb - About 1 hr to fix

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

          def destroy
        
            respond_to do |format|
              if @assay.can_delete?(current_user) && @assay.destroy
                format.html { redirect_to(assays_url) }
        Severity: Minor
        Found in app/controllers/assays_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

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

          def preview
            element=params[:element]
            assay  =Assay.find_by_id(params[:id])
        
            render :update do |page|
        Severity: Major
        Found in app/controllers/assays_controller.rb and 7 other locations - About 35 mins to fix
        app/controllers/data_files_controller.rb on lines 342..351
        app/controllers/events_controller.rb on lines 96..105
        app/controllers/models_controller.rb on lines 474..484
        app/controllers/presentations_controller.rb on lines 202..212
        app/controllers/samples_controller.rb on lines 214..224
        app/controllers/sops_controller.rb on lines 189..199
        app/controllers/workflows_controller.rb on lines 171..180

        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

             Array(organisms).each do |text|
              o_id, strain_title, strain_id, culture_growth_type_text,t_id,t_title=text.split(",")
              culture_growth=CultureGrowthType.find_by_title(culture_growth_type_text)
              @assay.associate_organism(o_id, strain_id, culture_growth,t_id,t_title)
        Severity: Minor
        Found in app/controllers/assays_controller.rb and 1 other location - About 25 mins to fix
        app/controllers/assays_controller.rb on lines 170..173

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

        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

            Array(organisms).each do |text|
                  o_id, strain,strain_id,culture_growth_type_text,t_id,t_title=text.split(",")
                  culture_growth=CultureGrowthType.find_by_title(culture_growth_type_text)
                  @assay.associate_organism(o_id, strain_id, culture_growth,t_id,t_title)
        Severity: Minor
        Found in app/controllers/assays_controller.rb and 1 other location - About 25 mins to fix
        app/controllers/assays_controller.rb on lines 106..109

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

        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

                flash.now[:error]="Unable to delete the assay" if !@assay.study.nil?
                format.html { render :action=>"show" }
                format.xml { render :xml => @assay.errors, :status => :unprocessable_entity }
        Severity: Minor
        Found in app/controllers/assays_controller.rb and 1 other location - About 20 mins to fix
        app/controllers/specimens_controller.rb on lines 133..135

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

        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

              @existing_assay.data_file_masters.each do |d|
                if !d.can_view?
                  flash.now[:notice] << "Some or all #{t('data_file').pluralize} of the existing #{t('assays.assay')} cannot be viewed, you may specify your own! <br/>".html_safe
                  break
                end
        Severity: Minor
        Found in app/controllers/assays_controller.rb and 2 other locations - About 20 mins to fix
        app/controllers/assays_controller.rb on lines 37..41
        app/controllers/assays_controller.rb on lines 43..47

        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

              @existing_assay.sop_masters.each do |s|
                if !s.can_view?
                  flash.now[:notice] << "Some or all #{t('sop').pluralize} of the existing #{t('assays.assay')} cannot be viewed, you may specify your own! <br/>".html_safe
                  break
                end
        Severity: Minor
        Found in app/controllers/assays_controller.rb and 2 other locations - About 20 mins to fix
        app/controllers/assays_controller.rb on lines 31..35
        app/controllers/assays_controller.rb on lines 43..47

        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

              @existing_assay.model_masters.each do |m|
                if !m.can_view?
                  flash.now[:notice] << "Some or all #{t('model').pluralize} of the existing #{t('assays.assay')} cannot be viewed, you may specify your own! <br/>".html_safe
                  break
                end
        Severity: Minor
        Found in app/controllers/assays_controller.rb and 2 other locations - About 20 mins to fix
        app/controllers/assays_controller.rb on lines 31..35
        app/controllers/assays_controller.rb on lines 37..41

        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

                  flash[:notice] = "#{t('assays.assay')} was successfully created."
                  format.html { redirect_to(@assay) }
                  format.xml { render :xml => @assay, :status => :created, :location => @assay }
        Severity: Minor
        Found in app/controllers/assays_controller.rb and 1 other location - About 15 mins to fix
        app/controllers/projects_controller.rb on lines 173..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 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