SpeciesFileGroup/taxonworks

View on GitHub
app/models/taxon_name_relationship/original_combination.rb

Summary

Maintainability
A
50 mins
Test Coverage

TODO found
Open

  #   TODO: reconcile this format with that of full_name_hash

TODO found
Open

  #   TODO: reconcile this with <>_name_elements for other combinations.

TODO found
Open

  # TODO: Why only ICN?

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

  def sv_validate_priority
    date1 = self.subject_taxon_name.cached_nomenclature_date
    date2 = self.object_taxon_name.cached_nomenclature_date
    if !!date1 && !!date2 && date1 > date2 && subject_invalid_statuses.empty?
      soft_validations.add(:type, "#{self.subject_status.capitalize} #{self.subject_taxon_name.cached_html_name_and_author_year} should not be younger than #{self.object_taxon_name.cached_html_name_and_author_year}")
Severity: Major
Found in app/models/taxon_name_relationship/original_combination.rb and 10 other locations - About 50 mins to fix
app/models/taxon_name_relationship/icn/accepting/conserved_name.rb on lines 39..44
app/models/taxon_name_relationship/icn/accepting/sanctioned_name.rb on lines 39..44
app/models/taxon_name_relationship/icnp/accepting/conserved_name.rb on lines 39..44
app/models/taxon_name_relationship/icvcn/unaccepting/supressed.rb on lines 48..53
app/models/taxon_name_relationship/iczn/invalidating/homonym/primary/forgotten.rb on lines 43..48
app/models/taxon_name_relationship/iczn/invalidating/homonym/primary/suppressed.rb on lines 34..39
app/models/taxon_name_relationship/iczn/invalidating/synonym/forgotten_name.rb on lines 43..48
app/models/taxon_name_relationship/iczn/invalidating/synonym/suppression.rb on lines 61..66
app/models/taxon_name_relationship/iczn/validating/conserved_name.rb on lines 67..72
app/models/taxon_name_relationship/iczn/validating/conserved_work.rb on lines 67..72

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

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 the new style validations validates :column, uniqueness: value over validates_uniqueness_of.
Open

  validates_uniqueness_of :object_taxon_name_id, scope: :type

This cop checks for the use of old-style attribute validation macros.

Example:

# bad
validates_acceptance_of :foo
validates_confirmation_of :foo
validates_exclusion_of :foo
validates_format_of :foo
validates_inclusion_of :foo
validates_length_of :foo
validates_numericality_of :foo
validates_presence_of :foo
validates_absence_of :foo
validates_size_of :foo
validates_uniqueness_of :foo

# good
validates :foo, acceptance: true
validates :foo, confirmation: true
validates :foo, exclusion: true
validates :foo, format: true
validates :foo, inclusion: true
validates :foo, length: true
validates :foo, numericality: true
validates :foo, presence: true
validates :foo, absence: true
validates :foo, size: true
validates :foo, uniqueness: true

There are no issues that match your filters.

Category
Status