muratguzel/letsrate

View on GitHub

Showing 7 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

            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