Showing 12 of 29 total issues
Function createInfoBox
has 103 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function createInfoBox(spot, payload) {
function changeColor(classList, currentClassName, newClassName) {
if (classList.contains(currentClassName)) {classList.remove(currentClassName)};
if (!classList.contains(newClassName)) {classList.add(newClassName)};
}
File html-manip.js
has 287 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { getGlobalOffset } from './positioning';
import { emit } from './events';
import state from './state';
import { isSafari } from './utils';
/*
Function addText
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function addText(container, payload, className) {
let text = document.createElement('div');
text.classList.add('feedback-text');
if (className) {
text.classList.add(className);
Function createToggleButton
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createToggleButton() {
let bottom = '25px';
let left = '25px';
let buttonContainer = document.createElement('div');
Function createInfoBox
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export function createInfoBox(spot, payload) {
function changeColor(classList, currentClassName, newClassName) {
if (classList.contains(currentClassName)) {classList.remove(currentClassName)};
if (!classList.contains(newClassName)) {classList.add(newClassName)};
}
- Read upRead up
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 generatePayload
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function generatePayload(event) {
const container = resolveContainer(event.target, state.currentStrategy);
if (!container) {
return;
}
Function clickListener
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function clickListener(event) {
if (!state.active) {
return;
}
closeInfoBox();
Function addBox
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function addBox(spot, toggled) {
spot.addEventListener('click', event => {
if (!state.active) {
return;
}
Function init
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
init(options) {
console.log('options', options);
options = options || {};
state.active = options.active || false
state.currentStrategy = options.strategy || strategies.global;
Function getSelector
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export function getSelector(e, child) {
if (e.tagName === 'BODY') {
return 'body' + (child ? " > " + child : "");
}
if (e.id) {
- Read upRead up
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 addTextField
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function addTextField(boxContainer, label, containerClass) {
let container = document.createElement('div');
if (containerClass) {
container.classList.add(containerClass)
};
Function addText
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export function addText(container, payload, className) {
let text = document.createElement('div');
text.classList.add('feedback-text');
if (className) {
text.classList.add(className);
- Read upRead up
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"