librariesio/libraries.io

View on GitHub
app/models/project_score_calculator.rb

Summary

Maintainability
D
1 day
Test Coverage

Class ProjectScoreCalculator has 56 methods (exceeds 20 allowed). Consider refactoring.
Open

class ProjectScoreCalculator
  def initialize(project, max_dependent_projects: nil, max_dependent_repositories: nil, max_stars: nil, max_forks: nil, max_watchers: nil)
    @project = project
    @max_dependent_projects = max_dependent_projects
    @max_dependent_repositories = max_dependent_repositories
Severity: Major
Found in app/models/project_score_calculator.rb - About 1 day to fix

    File project_score_calculator.rb has 315 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class ProjectScoreCalculator
      def initialize(project, max_dependent_projects: nil, max_dependent_repositories: nil, max_stars: nil, max_forks: nil, max_watchers: nil)
        @project = project
        @max_dependent_projects = max_dependent_projects
        @max_dependent_repositories = max_dependent_repositories
    Severity: Minor
    Found in app/models/project_score_calculator.rb - About 3 hrs to fix

      Method breakdown has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def breakdown
          {
            overall_score: overall_score,
            popularity: {
              score: popularity_score,
      Severity: Minor
      Found in app/models/project_score_calculator.rb - About 1 hr to fix

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

          def stars_score
            return nil if @project.repository.nil?
            return 0 if max_stars.zero? || @project.stars.zero?
            Math.log10(@project.stars)/Math.log10(max_stars)*100
        Severity: Minor
        Found in app/models/project_score_calculator.rb and 2 other locations - About 20 mins to fix
        app/models/project_score_calculator.rb on lines 107..110
        app/models/project_score_calculator.rb on lines 113..116

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

        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 watchers_score
            return nil if @project.repository.nil?
            return 0 if max_watchers.zero? || @project.watchers.zero?
            Math.log10(@project.watchers)/Math.log10(max_watchers)*100
        Severity: Minor
        Found in app/models/project_score_calculator.rb and 2 other locations - About 20 mins to fix
        app/models/project_score_calculator.rb on lines 101..104
        app/models/project_score_calculator.rb on lines 107..110

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

        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 forks_score
            return nil if @project.repository.nil?
            return 0 if max_forks.zero? || @project.forks.zero?
            Math.log10(@project.forks)/Math.log10(max_forks)*100
        Severity: Minor
        Found in app/models/project_score_calculator.rb and 2 other locations - About 20 mins to fix
        app/models/project_score_calculator.rb on lines 101..104
        app/models/project_score_calculator.rb on lines 113..116

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

        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

          def dependent_projects_score
            return nil unless platform_class::HAS_DEPENDENCIES
            return 0 if max_dependent_projects.zero? || @project.dependents_count.zero?
            Math.log10(@project.dependents_count)/Math.log10(max_dependent_projects)*100
        Severity: Minor
        Found in app/models/project_score_calculator.rb and 1 other location - About 15 mins to fix
        app/models/project_score_calculator.rb on lines 95..98

        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

          def dependent_repositories_score
            return nil unless platform_class::BIBLIOTHECARY_SUPPORT
            return 0 if max_dependent_repositories.zero? || @project.dependent_repos_count.zero?
            Math.log10(@project.dependent_repos_count)/Math.log10(max_dependent_repositories)*100
        Severity: Minor
        Found in app/models/project_score_calculator.rb and 1 other location - About 15 mins to fix
        app/models/project_score_calculator.rb on lines 89..92

        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

          def recent_releases_score
            return 0 unless published_releases.length > 0
            published_releases.any? {|v| v.published_at && v.published_at > 6.months.ago } ? 100 : 0
          end
        Severity: Minor
        Found in app/models/project_score_calculator.rb and 1 other location - About 15 mins to fix
        app/models/project_score_calculator.rb on lines 128..131

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

        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

          def brand_new_score
            return 0 unless published_releases.length > 0
            published_releases.any? {|v| v.published_at && v.published_at < 6.months.ago } ? 100 : 0
          end
        Severity: Minor
        Found in app/models/project_score_calculator.rb and 1 other location - About 15 mins to fix
        app/models/project_score_calculator.rb on lines 123..126

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

        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