muratguzel/letsrate

View on GitHub

Showing 9 of 9 total issues

File jquery.raty.js has 354 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * jQuery Raty - A Star Rating Plugin - http://wbotelhos.com/raty
 * -------------------------------------------------------------------
 *
 * jQuery Raty is a plugin that generates a customizable star rating.
Severity: Minor
Found in lib/generators/letsrate/templates/jquery.raty.js - About 4 hrs to fix

    Function init has 61 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            init: function(settings) {
                return this.each(function() {
                    var self    = this,
                        $this    = $(self).empty();
    
    
    Severity: Major
    Found in lib/generators/letsrate/templates/jquery.raty.js - About 2 hrs to fix

      Function bindAction has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              }, bindAction: function() {
                  var self    = this,
                      $this    = $(self);
      
                  $this.mouseleave(function() {
      Severity: Major
      Found in lib/generators/letsrate/templates/jquery.raty.js - About 2 hrs to fix

        Function setTarget has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                }, setTarget: function(value, isKeep) {
                    if (this.opt.target) {
                        var $target = $(this.opt.target);
        
                        if ($target.length == 0) {
        Severity: Minor
        Found in lib/generators/letsrate/templates/jquery.raty.js - About 1 hr to fix

          Function fill has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  }, fill: function(score) {
                      var self    = this,
                          number    = self.stars.length,
                          count    = 0,
                          $star    ,
          Severity: Minor
          Found in lib/generators/letsrate/templates/jquery.raty.js - About 1 hr to fix

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

                                if (self.opt.single) {
                                    icon = (i == score) ? (star.on || self.opt.starOn) : (star.off || self.opt.starOff);
                                } else {
            Severity: Minor
            Found in lib/generators/letsrate/templates/jquery.raty.js and 1 other location - About 50 mins to fix
            lib/generators/letsrate/templates/jquery.raty.js on lines 240..242

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

            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

                                } else {
                                    icon = (i <= score) ? (star.on || self.opt.starOn) : (star.off || self.opt.starOff);
                                }
            Severity: Minor
            Found in lib/generators/letsrate/templates/jquery.raty.js and 1 other location - About 50 mins to fix
            lib/generators/letsrate/templates/jquery.raty.js on lines 238..240

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

            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 rating_for_user has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def rating_for_user(rateable_obj, rating_user, dimension = nil, options = {})
                @object = rateable_obj
                @user = rating_user
                  @rating = Rate.find_by_rater_id_and_rateable_id_and_dimension(@user.id, @object.id, dimension)
                  stars = @rating ? @rating.stars : 0
            Severity: Minor
            Found in lib/letsrate/helpers.rb - About 35 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

            Method rate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def rate(stars, user, dimension=nil, dirichlet_method=false)
                dimension = nil if dimension.blank?
            
                if can_rate? user, dimension
                  rates(dimension).create! do |r|
            Severity: Minor
            Found in lib/letsrate/model.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

            Severity
            Category
            Status
            Source
            Language