Showing 12 of 12 total issues
File raty.js
has 571 lines of code (exceeds 250 allowed). Consider refactoring. Open
/*!
* Raty - A Star Rating Plugin
*
* author: Washington Botelho
* github: wbotelhos/raty
- Create a ticketCreate a ticket
Raty
has 52 functions (exceeds 20 allowed). Consider refactoring. Open
class Raty {
/**
*
* @param {object} element
* @param {object} options
- Create a ticketCreate a ticket
Function _getHint
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
_getHint(score, evt) {
if (score !== 0 && !score) {
return this.opt.noRatedMsg;
}
- Read upRead up
- Create a ticketCreate a ticket
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
Function _target
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
_target(score, evt) {
if (this.opt.target) {
const target = document.querySelector(this.opt.target);
if (!target) {
- Read upRead up
- Create a ticketCreate a ticket
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
Function _fill
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
_fill(score) {
let hash = 0;
if (this.opt.iconRangeSame && this.opt.iconRange) {
while (hash < this.opt.iconRange.length && this.opt.iconRange[hash].range < score) {
- Read upRead up
- Create a ticketCreate a ticket
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
Function _adjustHints
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
_adjustHints() {
// TODO: is it possible `hints` does not exist?
if (!this.opt.hints) {
this.opt.hints = [];
}
- Read upRead up
- Create a ticketCreate a ticket
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
Function defaultOptions
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
defaultOptions() {
return {
cancelButton: false,
cancelClass: 'raty-cancel',
cancelHint: 'Cancel this rating!',
- Create a ticketCreate a ticket
Function init
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
init() {
this._executeCallbacks();
this._adjustNumber();
this._adjustHints();
- Create a ticketCreate a ticket
Function _starName
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
_starName(score, evt) {
const decimal = +(score % 1).toFixed(2);
if (evt || this.isMove) {
return decimal > 0.5 ? 'starOn' : 'starHalf';
- Read upRead up
- Create a ticketCreate a ticket
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
Function _executeCallbacks
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
_executeCallbacks() {
const options = ['number', 'readOnly', 'score', 'scoreName', 'target', 'path'];
for (let i = 0; i < options.length; i++) {
if (typeof this.opt[options[i]] === 'function') {
- Read upRead up
- Create a ticketCreate a ticket
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
Avoid too many return
statements within this function. Open
return 'starOn'; // Up: [x.26 ...] || [x.6 ...]
- Create a ticketCreate a ticket
Function _createStars
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
_createStars() {
for (let i = 1; i <= this.opt.number; i++) {
const attributes = this._attributesForIndex(i);
let star = document.createElement(this.opt.starType);
- Read upRead up
- Create a ticketCreate a ticket
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"