File directive.js
has 272 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { watch } from 'vue';
export const CLOSING_COMMENT = '//';
export const NAMESPACE = 'vue-hubble';
export const ENV_WILDCARD = '*';
Function addTooltip
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const addTooltip = (target, id) => {
const { top, left, width } = target.getBoundingClientRect();
const selector = target.getAttribute(`${NAMESPACE}-selector`);
const text = getTooltip(selector);
const tooltip = document.createElement('span');
Function getGenericSelector
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export const getGenericSelector = (instance, vnode, value) => {
if (!value) return '';
const namespaces = [value];
const enableDeepNamespacing = $hubble.enableDeepNamespacing;
- 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 handleMountedAndUpdated
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export const handleMountedAndUpdated = async (element, { instance, arg, value, oldValue }, vnode) => {
if (!inCorrectEnvironment()) {
if (element.hubbleMouseover) {
document.removeEventListener('mouseover', element.hubbleMouseover);
element.hubbleMouseover = undefined;
- 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 handleHubbleSelector
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export const handleHubbleSelector = ({ arg, element, oldSelector, newSelector, newQuerySelector }) => {
switch (arg) {
case 'class':
oldSelector && element.classList.remove(oldSelector);
if (newSelector) {
- 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 get
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export const get = (obj, path, defaultValue) => {
const travel = (regexp) =>
String.prototype.split
.call(path, regexp)
.filter(Boolean)
- 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 handleMouseover
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export const handleMouseover = (instance, element, id) => (event) => {
const { target } = event;
const oldTooltip = document.querySelector(`[${NAMESPACE}-tooltip-id="${id}"]`);
const oldHighlight = document.querySelector(`[${NAMESPACE}-highlight-id="${id}"]`);
const shouldRender = target === element || target === oldTooltip || element.contains(target);
- 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"