CrazySquirrel/Utils

View on GitHub
lib/UtilsDOM.ts

Summary

Maintainability
D
1 day
Test Coverage

File UtilsDOM.ts has 288 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";
/**
 * Import additional classes
 */
import UtilsMain from "./UtilsMain";
Severity: Minor
Found in lib/UtilsDOM.ts - About 2 hrs to fix

Function getBoundingClientRect has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public static getBoundingClientRect(domNode: any, domDocument: Document = document, showForce: boolean = false): {
    bottom: number,
    height: number,
    left: number,
    right: number,
Severity: Major
Found in lib/UtilsDOM.ts - About 2 hrs to fix

Consider simplifying this complex logical expression.
Open

    if (
        !domNode ||
        domNode.nodeType !== 1 || !domNode.parentNode ||
        domNode.parentNode.nodeName === "HTML" ||
        (
Severity: Critical
Found in lib/UtilsDOM.ts - About 1 hr to fix

Function getBoundingClientRect has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  public static getBoundingClientRect(domNode: any, domDocument: Document = document, showForce: boolean = false): {
    bottom: number,
    height: number,
    left: number,
    right: number,
Severity: Minor
Found in lib/UtilsDOM.ts - About 1 hr 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

Function getDOMNode has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public static getDOMNode(domNode: any, domDocument: Document = document): Element | boolean {
    /**
     * Check if domDocument is a valid variable
     */
    if (!DOM.isDOMDocument(domDocument)) {
Severity: Minor
Found in lib/UtilsDOM.ts - About 1 hr to fix

Function findElementPosition has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public static findElementPosition(domNode: any, domDocument: Document = document, showForce: boolean = false) {
    const objRet = {
      left: 0,
      top: 0,
    };
Severity: Minor
Found in lib/UtilsDOM.ts - About 1 hr to fix

Function findElementPosition has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  public static findElementPosition(domNode: any, domDocument: Document = document, showForce: boolean = false) {
    const objRet = {
      left: 0,
      top: 0,
    };
Severity: Minor
Found in lib/UtilsDOM.ts - About 55 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

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

  public static getDOMNode(domNode: any, domDocument: Document = document): Element | boolean {
    /**
     * Check if domDocument is a valid variable
     */
    if (!DOM.isDOMDocument(domDocument)) {
Severity: Minor
Found in lib/UtilsDOM.ts - About 45 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

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

  public static removeClassName(element: HTMLElement, className: string): HTMLElement {
    if (
        element &&
        typeof element === "object" &&
        typeof className === "string" &&
Severity: Minor
Found in lib/UtilsDOM.ts - About 45 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

Function addClassName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  public static addClassName(element: HTMLElement, className: string): HTMLElement {
    if (
        element &&
        typeof element === "object" &&
        typeof className === "string" &&
Severity: Minor
Found in lib/UtilsDOM.ts - 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

Function toggleClassName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  public static toggleClassName(element: HTMLElement, className: string, toggle: boolean): HTMLElement {
    if (
        element &&
        typeof element === "object" &&
        typeof className === "string" &&
Severity: Minor
Found in lib/UtilsDOM.ts - 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

There are no issues that match your filters.

Category
Status