Grupo-AFAL/frontend-helpers

View on GitHub
javascript/src/controllers/step-number-input-controller.js

Summary

Maintainability
B
5 hrs
Test Coverage

Showing 5 of 5 total issues

Function setValue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

setValue () {
this.value = Math.max(Math.min(this.value, this.maxValue), this.minValue)
this.inputTarget.value = this.value
 
if (this.hasAddTarget) {
Severity: Minor
Found in javascript/src/controllers/step-number-input-controller.js - About 45 mins to fix

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

if (this.hasAddTarget) {
if (this.value === this.maxValue) {
this.addTarget.classList.add('is-static')
} else {
this.addTarget.classList.remove('is-static')
Severity: Major
Found in javascript/src/controllers/step-number-input-controller.js and 1 other location - About 1 hr to fix
javascript/src/controllers/step-number-input-controller.js on lines 48..54

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

if (this.hasSubtractTarget) {
if (this.value === this.minValue) {
this.subtractTarget.classList.add('is-static')
} else {
this.subtractTarget.classList.remove('is-static')
Severity: Major
Found in javascript/src/controllers/step-number-input-controller.js and 1 other location - About 1 hr to fix
javascript/src/controllers/step-number-input-controller.js on lines 40..46

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

add (e) {
e.preventDefault()
this.value += 1
this.setValue()
this.triggerChangeEvent()
Severity: Minor
Found in javascript/src/controllers/step-number-input-controller.js and 1 other location - About 45 mins to fix
javascript/src/controllers/step-number-input-controller.js on lines 29..34

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

subtract (e) {
e.preventDefault()
this.value -= 1
this.setValue()
this.triggerChangeEvent()
Severity: Minor
Found in javascript/src/controllers/step-number-input-controller.js and 1 other location - About 45 mins to fix
javascript/src/controllers/step-number-input-controller.js on lines 22..27

There are no issues that match your filters.

Category
Status