unepwcmc/SAPI

View on GitHub
lib/modules/sapi_module/summary.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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

    def self.taxonomy_kingdom_stats(taxonomy, kingdom)
      stats = {}
      t = Taxonomy.find_by_name(taxonomy)
      k = TaxonConcept.find_by_full_name_and_taxonomy_id(kingdom, t.id)
      stats[:accepted_taxa] = TaxonConcept.where(
Severity: Minor
Found in lib/modules/sapi_module/summary.rb - About 1 hr to fix

    Method database_summary has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.database_summary
          puts "#############################################################"
          puts "#################                  ##########################"
          puts "################# Database Summary ##########################"
          puts "#################                  ##########################"
    Severity: Minor
    Found in lib/modules/sapi_module/summary.rb - About 1 hr to fix

      Method kingdom_summary has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.kingdom_summary(t, k)
            puts "#############################################################"
            puts "#############################################################"
            puts ">>> #{k.full_name} general stats"
      
      
      Severity: Minor
      Found in lib/modules/sapi_module/summary.rb - About 1 hr to fix

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

            def self.trade_stats
              trade = {}
              trade[:terms] = Term.count
              trade[:sources] = Source.count
              trade[:units] = Unit.count
        Severity: Minor
        Found in lib/modules/sapi_module/summary.rb and 2 other locations - About 15 mins to fix
        lib/modules/sapi_module/summary.rb on lines 19..25
        lib/modules/sapi_module/summary.rb on lines 68..74

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

            def self.core_stats
              core = {}
              core[:taxonomies] = Taxonomy.count
              core[:designations] = Designation.count
              core[:instruments] = Instrument.count
        Severity: Minor
        Found in lib/modules/sapi_module/summary.rb and 2 other locations - About 15 mins to fix
        lib/modules/sapi_module/summary.rb on lines 59..65
        lib/modules/sapi_module/summary.rb on lines 68..74

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

            def self.trade_restrictions_stats
              trade = {}
              trade[:quotas] = Quota.count
              trade[:cites_suspensions] = CitesSuspension.count
              trade[:eu_opinions] = EuOpinion.count
        Severity: Minor
        Found in lib/modules/sapi_module/summary.rb and 2 other locations - About 15 mins to fix
        lib/modules/sapi_module/summary.rb on lines 19..25
        lib/modules/sapi_module/summary.rb on lines 59..65

        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