SpeciesFileGroup/taxonworks

View on GitHub
app/helpers/observation_matrices/export/nexml_helper.rb

Summary

Maintainability
C
1 day
Test Coverage

Method has too many lines. [53/25]
Open

  def nexml_descriptors(options = {})
    opt = {target: ''}.merge!(options)
    xml = Builder::XmlMarkup.new(target: opt[:target])
    m = opt[:observation_matrix]

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method include_multistate_matrix has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

  def include_multistate_matrix(options = {})
    opt = {target: '', descriptors: []}.merge!(options)
    xml = Builder::XmlMarkup.new(target: opt[:target])

    m = opt[:observation_matrix]
Severity: Minor
Found in app/helpers/observation_matrices/export/nexml_helper.rb - About 4 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 has too many lines. [38/25]
Open

  def include_multistate_matrix(options = {})
    opt = {target: '', descriptors: []}.merge!(options)
    xml = Builder::XmlMarkup.new(target: opt[:target])

    m = opt[:observation_matrix]

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method nexml_descriptors has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def nexml_descriptors(options = {})
    opt = {target: ''}.merge!(options)
    xml = Builder::XmlMarkup.new(target: opt[:target])
    m = opt[:observation_matrix]

Severity: Major
Found in app/helpers/observation_matrices/export/nexml_helper.rb - About 2 hrs to fix

    Method include_multistate_matrix has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def include_multistate_matrix(options = {})
        opt = {target: '', descriptors: []}.merge!(options)
        xml = Builder::XmlMarkup.new(target: opt[:target])
    
        m = opt[:observation_matrix]
    Severity: Minor
    Found in app/helpers/observation_matrices/export/nexml_helper.rb - About 1 hr to fix

      Method nexml_descriptors has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def nexml_descriptors(options = {})
          opt = {target: ''}.merge!(options)
          xml = Builder::XmlMarkup.new(target: opt[:target])
          m = opt[:observation_matrix]
      
      
      Severity: Minor
      Found in app/helpers/observation_matrices/export/nexml_helper.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 include_continuous_matrix has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def include_continuous_matrix(options = {})
          opt = {target:  '', descriptors: []}.merge!(options)
          xml = Builder::XmlMarkup.new(target: opt[:target])
          m = opt[:observation_matrix]
      
      
      Severity: Minor
      Found in app/helpers/observation_matrices/export/nexml_helper.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

                    uncertain.keys.each do |pc|
                      xml.uncertain_state_set(id: "cs#{c.id}unc_#{uncertain[pc].sort.join}", symbol: pc) do
                        uncertain[pc].collect{|m| xml.member(state: "cs_#{m}") } # m is built in pcfd
      Severity: Minor
      Found in app/helpers/observation_matrices/export/nexml_helper.rb and 1 other location - About 35 mins to fix
      app/helpers/observation_matrices/export/nexml_helper.rb on lines 32..34

      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

                    uncertain.keys.each do |pc|
                      xml.uncertain_state_set(id: "cs#{c.id}unc_#{uncertain[pc].sort.join}", symbol: pc) do
                        uncertain[pc].collect{|m| xml.member(state: "cs#{m}") }
      Severity: Minor
      Found in app/helpers/observation_matrices/export/nexml_helper.rb and 1 other location - About 35 mins to fix
      app/helpers/observation_matrices/export/nexml_helper.rb on lines 46..48

      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

      Prefer symbols instead of strings as hash keys.
      Open

                xml.meta('UNDEFINED', 'xsi:type' => 'LiteralMeta', 'property' => 'dwc:collectionID') 

      This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

      Example:

      # bad
      { 'one' => 1, 'two' => 2, 'three' => 3 }
      
      # good
      { one: 1, two: 2, three: 3 }

      Prefer symbols instead of strings as hash keys.
      Open

            'xsi:type' => 'nex:StandardCells',

      This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

      Example:

      # bad
      { 'one' => 1, 'two' => 2, 'three' => 3 }
      
      # good
      { one: 1, two: 2, three: 3 }

      Prefer symbols instead of strings as hash keys.
      Open

            xml.meta('xsi:type' => 'ResourceMeta', 'rel' => 'dwc:individualID') do

      This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

      Example:

      # bad
      { 'one' => 1, 'two' => 2, 'three' => 3 }
      
      # good
      { one: 1, two: 2, three: 3 }

      Prefer symbols instead of strings as hash keys.
      Open

                xml.meta(a.namespace.name, 'xsi:type' => 'LiteralMeta', 'property' => 'dwc:collectionID') 

      This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

      Example:

      # bad
      { 'one' => 1, 'two' => 2, 'three' => 3 }
      
      # good
      { one: 1, two: 2, three: 3 }

      Prefer single-quoted strings when you don't need string interpolation or special symbols.
      Open

                    xml.state(id: "cs_#{c.id}_1", label: 'present', symbol: "1")

      Checks if uses of quotes match the configured preference.

      Example: EnforcedStyle: single_quotes (default)

      # bad
      "No special symbols"
      "No string interpolation"
      "Just text"
      
      # good
      'No special symbols'
      'No string interpolation'
      'Just text'
      "Wait! What's #{this}!"

      Example: EnforcedStyle: double_quotes

      # bad
      'Just some text'
      'No special chars or interpolation'
      
      # good
      "Just some text"
      "No special chars or interpolation"
      "Every string in #{project} uses double_quotes"

      Prefer symbols instead of strings as hash keys.
      Open

                xml.meta('UNDEFINED', 'xsi:type' => 'LiteralMeta', 'property' => 'dwc:collectionID') 

      This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

      Example:

      # bad
      { 'one' => 1, 'two' => 2, 'three' => 3 }
      
      # good
      { one: 1, two: 2, three: 3 }

      Prefer single-quoted strings when you don't need string interpolation or special symbols.
      Open

                      state = "ERROR"

      Checks if uses of quotes match the configured preference.

      Example: EnforcedStyle: single_quotes (default)

      # bad
      "No special symbols"
      "No string interpolation"
      "Just text"
      
      # good
      'No special symbols'
      'No string interpolation'
      'Just text'
      "Wait! What's #{this}!"

      Example: EnforcedStyle: double_quotes

      # bad
      'Just some text'
      'No special chars or interpolation'
      
      # good
      "Just some text"
      "No special chars or interpolation"
      "Every string in #{project} uses double_quotes"

      Prefer symbols instead of strings as hash keys.
      Open

            xml.meta('xsi:type' => 'ResourceMeta', 'rel' => 'dwc:individualID') do

      This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

      Example:

      # bad
      { 'one' => 1, 'two' => 2, 'three' => 3 }
      
      # good
      { one: 1, two: 2, three: 3 }

      Prefer single-quoted strings when you don't need string interpolation or special symbols.
      Open

                    xml.state(id: "missing#{c.id}", symbol: '2', label: "?")

      Checks if uses of quotes match the configured preference.

      Example: EnforcedStyle: single_quotes (default)

      # bad
      "No special symbols"
      "No string interpolation"
      "Just text"
      
      # good
      'No special symbols'
      'No string interpolation'
      'Just text'
      "Wait! What's #{this}!"

      Example: EnforcedStyle: double_quotes

      # bad
      'Just some text'
      'No special chars or interpolation'
      
      # good
      "Just some text"
      "No special chars or interpolation"
      "Every string in #{project} uses double_quotes"

      Prefer symbols instead of strings as hash keys.
      Open

                xml.meta(a.identifier, 'xsi:type' => 'LiteralMeta', 'property' => 'dwc:catalogNumber') 

      This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

      Example:

      # bad
      { 'one' => 1, 'two' => 2, 'three' => 3 }
      
      # good
      { one: 1, two: 2, three: 3 }

      Prefer symbols instead of strings as hash keys.
      Open

                xml.meta(s.id, 'xsi:type' => 'LiteralMeta', 'property' => 'dwc:catalogNumber') 

      This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

      Example:

      # bad
      { 'one' => 1, 'two' => 2, 'three' => 3 }
      
      # good
      { one: 1, two: 2, three: 3 }

      Prefer symbols instead of strings as hash keys.
      Open

                xml.meta(a.namespace.name, 'xsi:type' => 'LiteralMeta', 'property' => 'dwc:collectionID') 

      This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

      Example:

      # bad
      { 'one' => 1, 'two' => 2, 'three' => 3 }
      
      # good
      { one: 1, two: 2, three: 3 }

      Prefer single-quoted strings when you don't need string interpolation or special symbols.
      Open

                    xml.state(id: "cs_#{c.id}_0", label: 'absent', symbol: "0")

      Checks if uses of quotes match the configured preference.

      Example: EnforcedStyle: single_quotes (default)

      # bad
      "No special symbols"
      "No string interpolation"
      "Just text"
      
      # good
      'No special symbols'
      'No string interpolation'
      'Just text'
      "Wait! What's #{this}!"

      Example: EnforcedStyle: double_quotes

      # bad
      'Just some text'
      'No special chars or interpolation'
      
      # good
      "Just some text"
      "No special chars or interpolation"
      "Every string in #{project} uses double_quotes"

      Prefer symbols instead of strings as hash keys.
      Open

            'xsi:type' => 'nex:ContinuousCells',

      This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

      Example:

      # bad
      { 'one' => 1, 'two' => 2, 'three' => 3 }
      
      # good
      { one: 1, two: 2, three: 3 }

      Prefer symbols instead of strings as hash keys.
      Open

                xml.meta(a.identifier, 'xsi:type' => 'LiteralMeta', 'property' => 'dwc:catalogNumber') 

      This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

      Example:

      # bad
      { 'one' => 1, 'two' => 2, 'three' => 3 }
      
      # good
      { one: 1, two: 2, three: 3 }

      Prefer symbols instead of strings as hash keys.
      Open

                xml.meta(s.id, 'xsi:type' => 'LiteralMeta', 'property' => 'dwc:catalogNumber') 

      This cop checks for the use of strings as keys in hashes. The use of symbols is preferred instead.

      Example:

      # bad
      { 'one' => 1, 'two' => 2, 'three' => 3 }
      
      # good
      { one: 1, two: 2, three: 3 }

      Prefer single-quoted strings when you don't need string interpolation or special symbols.
      Open

                    xml.state(id: "missing#{c.id}", symbol: c.character_states.size, label: "?")

      Checks if uses of quotes match the configured preference.

      Example: EnforcedStyle: single_quotes (default)

      # bad
      "No special symbols"
      "No string interpolation"
      "Just text"
      
      # good
      'No special symbols'
      'No string interpolation'
      'Just text'
      "Wait! What's #{this}!"

      Example: EnforcedStyle: double_quotes

      # bad
      'Just some text'
      'No special chars or interpolation'
      
      # good
      "Just some text"
      "No special chars or interpolation"
      "Every string in #{project} uses double_quotes"

      There are no issues that match your filters.

      Category
      Status