SpeciesFileGroup/taxonworks

View on GitHub

Showing 12,624 of 12,624 total issues

Method extract_dates has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def self.extract_dates(trial, match_data)
    end_date_year, end_date_month, end_date_day = 0, 0, 0
    case trial[:method].downcase.to_sym
      when :month_dd_yyyy_2
        start_date_year = 3
Severity: Minor
Found in lib/utilities/dates.rb - About 3 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 gpx_to_csv has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def self.gpx_to_csv(gpx_file, csv_options = {col_sep: "\t", headers: true, encoding: 'UTF-8', write_headers: true})
    gpx_headers = %w(name geojson start_date end_date minimum_elevation maximum_elevation)

    csv_string = CSV.generate(**csv_options) do |csv|
      csv << gpx_headers
Severity: Minor
Found in lib/vendor/gpx_to_csv.rb - About 3 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 hunt_lat_long has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def self.hunt_lat_long(label, how = ' ')
      if how.nil?
        pieces = [label]
      else
        pieces = label.split(how)
Severity: Minor
Found in lib/utilities/geo.rb - About 3 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

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

  function getObservation (observation) {
    if (observations.length) {
      const o = observations.find(o => o.id === observation.id)

      if (o) { return o }
app/javascript/vue/tasks/observation_matrices/matrix_row_coder/store/mutations/setObservation.js on lines 29..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 100.

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

  function getObservation (observation) {
    if (observations.length) {
      const o = observations.find(o => o.id === observation.id)

      if (o) { return o }
app/javascript/vue/tasks/observation_matrices/matrix_column_coder/store/mutations/setObservation.js on lines 27..39

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

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

function imageSVGViewBox (id, box, imageWidth, imageHeight) {
  const [x, y, width, height] = box.split(' ')
  return `/images/${id}/scale_to_box/${Math.floor(x)}/${Math.floor(y)}/${Math.floor(width)}/${Math.floor(height)}/${imageWidth}/${imageHeight}`
}
Severity: Major
Found in app/javascript/vue/helpers/images.js and 1 other location - About 3 hrs to fix
app/javascript/vue/helpers/images.js on lines 6..9

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

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

function imageScale (id, box, imageWidth, imageHeight) {
  const [x, y, width, height] = box.split(' ')
  return `/images/${id}/scale/${Math.floor(x)}/${Math.floor(y)}/${Math.floor(width)}/${Math.floor(height)}/${imageWidth}/${imageHeight}`
}
Severity: Major
Found in app/javascript/vue/helpers/images.js and 1 other location - About 3 hrs to fix
app/javascript/vue/helpers/images.js on lines 1..4

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

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

File image_matrix.rb has 302 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Tools::ImageMatrix

  ##### FILTER PARAMETERS #####

  # @!observation_matrix_id
Severity: Minor
Found in lib/tools/image_matrix.rb - About 3 hrs to fix

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

    function bind_definition_listener(form) {
        form.find(".definition").keyup(function() {
          var d = form.find(".definition").val();
          if (d.length == 0) {
            $(".citation_topic_picker_add_new").hide();
    Severity: Major
    Found in app/assets/javascripts/views/citations/_topic_picker.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/views/tags/tag_picker.js on lines 149..160

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

    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

      bind_definition_listener: function (form) {
        form.find(".definition").keyup(function () {
          var d = form.find(".definition").val();
    
          if (d.length == 0) {
    Severity: Major
    Found in app/assets/javascripts/views/tags/tag_picker.js and 1 other location - About 3 hrs to fix
    app/assets/javascripts/views/citations/_topic_picker.js on lines 53..63

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

    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

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

      def using_iccn_class
        unless identifier.nil?
          lccn = identifier
    
          # '200112345', '2010549727', '2003064850', '|a  2003064850', '88156495', '68-004897', '2001-459440'

    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 has too many lines. [38/25]
    Open

      def sv_fix_objective_synonym_relationship
        fixed = false
        s = self.subject_taxon_name
        o = self.object_taxon_name
        if s.get_primary_type.empty?

    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 has too many lines. [38/25]
    Open

      def set_cached_names_for_taxon_names
        # !! only fire if subject_taxon_name changed
        return true unless subject_taxon_name_id_previously_changed? || destroyed?
    
        TaxonName.transaction do

    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 has too many lines. [38/25]
    Open

      def dwc_occurrences_metadata(dwc_occurrences = nil, project_id: nil)
        records = dwc_occurrences
        project_id ||= sessions_current_project_id
    
        # Anticipate multiple sources of records in future (e.g. AssertedDistribution)

    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 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 has too many lines. [38/25]
    Open

      def self.generate(otus, project_members, reference_csv = nil)
        ::CSV.generate(col_sep: "\t") do |csv|
    
          csv << %w{taxonID nameID status remarks referenceID modified modifiedBy}
    
    
    Severity: Minor
    Found in lib/export/coldp/files/synonym.rb by rubocop

    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 has too many lines. [38/25]
    Open

      def add_scopes_to_routes
        scopes = ['scope :tasks']
        scope_index = 0
    
        @paths.each do |path|

    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.

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

    const ActionFunctions = {
      [ActionNames.RequestDescription]: requestDescription,
      [ActionNames.RequestMatrixRow]: requestMatrixRow,
      [ActionNames.RequestObservations]: requestObservations,
      [ActionNames.RemoveObservation]: removeObservation,
    app/javascript/vue/tasks/dwca_import/store/actions/actions.js on lines 14..25
    app/javascript/vue/tasks/images/new_image/const/layout.js on lines 25..36
    app/javascript/vue/tasks/observation_matrices/new/store/actions/actions.js on lines 13..24
    app/javascript/vue/tasks/observation_matrices/new/store/getters/getters.js on lines 25..36

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

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

    const GetterFunctions = {
      [GetterNames.GetMatrix]: getMatrix,
      [GetterNames.GetMatrixRows]: getMatrixRows,
      [GetterNames.GetMatrixRowsDynamic]: getMatrixRowsDynamic,
      [GetterNames.GetMatrixView]: getMatrixView,
    app/javascript/vue/tasks/dwca_import/store/actions/actions.js on lines 14..25
    app/javascript/vue/tasks/images/new_image/const/layout.js on lines 25..36
    app/javascript/vue/tasks/observation_matrices/matrix_row_coder/store/actions/actions.js on lines 14..25
    app/javascript/vue/tasks/observation_matrices/new/store/actions/actions.js on lines 13..24

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

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

    const ActionFunctions = {
      [ActionNames.CreateRowItem]: createRowItem,
      [ActionNames.CreateColumnItem]: createColumnItem,
      [ActionNames.LoadMatrix]: loadMatrix,
      [ActionNames.GetMatrixObservationRows]: getMatrixObservationRows,
    app/javascript/vue/tasks/dwca_import/store/actions/actions.js on lines 14..25
    app/javascript/vue/tasks/images/new_image/const/layout.js on lines 25..36
    app/javascript/vue/tasks/observation_matrices/matrix_row_coder/store/actions/actions.js on lines 14..25
    app/javascript/vue/tasks/observation_matrices/new/store/getters/getters.js on lines 25..36

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

    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

    Severity
    Category
    Status
    Source
    Language