Samhane/incubator-taverna-databundle-viewer

View on GitHub
app/models/provenance.rb

Summary

Maintainability
F
1 wk
Test Coverage

Method to_dataHashObject has a Cognitive Complexity of 166 (exceeds 5 allowed). Consider refactoring.
Open

  def to_dataHashObject(bundle_filepath)

    nodes = []
    links = []

Severity: Minor
Found in app/models/provenance.rb - About 3 days 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 to_dataHashObject has 248 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def to_dataHashObject(bundle_filepath)

    nodes = []
    links = []

Severity: Major
Found in app/models/provenance.rb - About 1 day to fix

    File provenance.rb has 434 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'sparql'  # query the graph
    require 'uri'     # used to decode urls
    
    class Provenance
    
    
    Severity: Minor
    Found in app/models/provenance.rb - About 6 hrs to fix

      Method getAllArtifacts has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def getAllArtifacts
          # create the query
          sparql_query = SPARQL.parse("#{Provenance.prefixes}
            SELECT *
            WHERE
      Severity: Major
      Found in app/models/provenance.rb - About 2 hrs to fix

        Method getAllProcessRuns has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def getAllProcessRuns
            sparql_query = SPARQL.parse("#{Provenance.prefixes}   
              SELECT *
              WHERE
              { 
        Severity: Minor
        Found in app/models/provenance.rb - About 1 hr to fix

          Method getAllWorkflowRuns has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def getAllWorkflowRuns
              # create the query
              sparql_query = SPARQL.parse("#{Provenance.prefixes}
                SELECT *
                WHERE
          Severity: Minor
          Found in app/models/provenance.rb - About 1 hr to fix

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

                  if result["wasPartOfWorkflow"].present?
            
                    workflowRunLabel = result["wasPartOfWorkflowLabel"].to_s
                    if workflowRunLabel[0] == "W"
                      workflowRunLabel = workflowRunLabel[workflowRunTrimCount, workflowRunLabel.length]
            Severity: Major
            Found in app/models/provenance.rb and 2 other locations - About 1 hr to fix
            app/models/provenance.rb on lines 247..268
            app/models/provenance.rb on lines 502..524

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

            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

                  if result["outputFromWorkflowRun"].present?
                    workflowRunLabel = result["outputFromWorkflowRunLabel"].to_s
            
                    if workflowRunLabel[0] == "W"
                      workflowRunLabel = workflowRunLabel[workflowRunTrimCount, workflowRunLabel.length]
            Severity: Major
            Found in app/models/provenance.rb and 2 other locations - About 1 hr to fix
            app/models/provenance.rb on lines 247..268
            app/models/provenance.rb on lines 333..356

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

            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

                  if result["wasPartOfWorkflowRun"].present?
            
                    secondWorkflowRunLabel = result["wasPartOfWorkflowRunLabel"].to_s
                    if secondWorkflowRunLabel[0] == "W"
                      secondWorkflowRunLabel = secondWorkflowRunLabel[workflowRunTrimCount, secondWorkflowRunLabel.length]
            Severity: Major
            Found in app/models/provenance.rb and 2 other locations - About 1 hr to fix
            app/models/provenance.rb on lines 333..356
            app/models/provenance.rb on lines 502..524

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

            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

                  if result["usedDictionaryInput"].present?
                    dictionary = {:name => result["usedDictionaryInput"].to_s, :type => "Dictionary" }
            
                    indexTarget = nodes.find_index(artifact)
            
            
            Severity: Major
            Found in app/models/provenance.rb and 3 other locations - About 55 mins to fix
            app/models/provenance.rb on lines 273..286
            app/models/provenance.rb on lines 361..374
            app/models/provenance.rb on lines 379..392

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

            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

                  if result["usedArtifactInput"].present?
                    artifact = {:name => result["usedArtifactInput"].to_s, :type => "Artifact" }
            
                    indexTarget = nodes.find_index(artifact)
            
            
            Severity: Major
            Found in app/models/provenance.rb and 3 other locations - About 55 mins to fix
            app/models/provenance.rb on lines 273..286
            app/models/provenance.rb on lines 291..304
            app/models/provenance.rb on lines 379..392

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

            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

                  if result["usedArtifactInput"].present?
                    artifact = {:name => result["usedArtifactInput"].to_s, :type => "Artifact" }
            
                    indexTarget = nodes.find_index(artifact)
            
            
            Severity: Major
            Found in app/models/provenance.rb and 3 other locations - About 55 mins to fix
            app/models/provenance.rb on lines 291..304
            app/models/provenance.rb on lines 361..374
            app/models/provenance.rb on lines 379..392

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

            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

                  if result["usedDictionaryInput"].present?
                    dictionary = {:name => result["usedDictionaryInput"].to_s, :type => "Dictionary" }
            
                    indexTarget = nodes.find_index(artifact)
            
            
            Severity: Major
            Found in app/models/provenance.rb and 3 other locations - About 55 mins to fix
            app/models/provenance.rb on lines 273..286
            app/models/provenance.rb on lines 291..304
            app/models/provenance.rb on lines 361..374

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

            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

                    nodes.each_with_index do |node, index|
                      if node[:type].to_s == memberArtifact[:type].to_s
                        if node[:name].to_s == memberArtifact[:name].to_s
                          indexTarget = index
            Severity: Minor
            Found in app/models/provenance.rb and 1 other location - About 15 mins to fix
            app/models/provenance.rb on lines 570..573

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

            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

                    nodes.each_with_index do |node, index|
                      if node[:type].to_s == dictionary[:type].to_s
                        if node[:name].to_s == dictionary[:name].to_s
                          indexTarget = index
            Severity: Minor
            Found in app/models/provenance.rb and 1 other location - About 15 mins to fix
            app/models/provenance.rb on lines 533..536

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

            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