CrazySquirrel/CSTiles

View on GitHub
src/ts/Modules/CSTiles.ts

Summary

Maintainability
F
1 wk
Test Coverage

File CSTiles.ts has 792 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";
/**
 * Import interfaces
 */
import IWindow from "../Interfaces/IWindow";
Severity: Major
Found in src/ts/Modules/CSTiles.ts - About 1 day to fix

Function findPosition has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring.
Open

    public static findPosition(grid: Array<Array<boolean>>,
                               gridSize: number,
                               tileSize: Array<number>,
                               tilePosition: Array<number>): {x: number, y: number, grid: Array<Array<boolean>>} {
        let x;
Severity: Minor
Found in src/ts/Modules/CSTiles.ts - About 1 day 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 convertCss has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

    public static convertCss(arrCss: Object) {
        for (let strMedia in arrCss) {
            if (arrCss.hasOwnProperty(strMedia)) {
                for (let strBlockID in arrCss[strMedia]) {
                    if (arrCss[strMedia].hasOwnProperty(strBlockID)) {
Severity: Minor
Found in src/ts/Modules/CSTiles.ts - About 1 day 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 compiledCssProperties has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    public static compiledCssProperties(objCssProperties: Object): Object {
        let objCompiledRules = {
            background: [
                "background-image",
                "background-position/background-size",
Severity: Minor
Found in src/ts/Modules/CSTiles.ts - About 4 hrs 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 compiledCssProperties has 95 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static compiledCssProperties(objCssProperties: Object): Object {
        let objCompiledRules = {
            background: [
                "background-image",
                "background-position/background-size",
Severity: Major
Found in src/ts/Modules/CSTiles.ts - About 3 hrs to fix

Function constructor has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    constructor(domParentNode?: HTMLElement,
                objGridParams?: CGridParams,
                arrTiles?: Array<CTileParams>) {
        /**
         * Assign default params
Severity: Major
Found in src/ts/Modules/CSTiles.ts - About 3 hrs to fix

Function findPosition has 74 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static findPosition(grid: Array<Array<boolean>>,
                               gridSize: number,
                               tileSize: Array<number>,
                               tilePosition: Array<number>): {x: number, y: number, grid: Array<Array<boolean>>} {
        let x;
Severity: Major
Found in src/ts/Modules/CSTiles.ts - About 2 hrs to fix

CSTiles has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

export default class CSTiles {
    /**
     * Convert css object to css
     * @param arrCss
     * @returns {string}
Severity: Minor
Found in src/ts/Modules/CSTiles.ts - About 2 hrs to fix

Function optimizeCssProperty has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public static optimizeCssProperty(strCssPropertyName, strCssPropertyValue): string {
        strCssPropertyValue = (" " + strCssPropertyValue + " ")
            .replace(/\s0%/ig, " 0")
            .replace(/[\r\n\t]/ig, " ")
            .replace(/\s+/ig, " ")
Severity: Minor
Found in src/ts/Modules/CSTiles.ts - About 2 hrs 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 checkInnerParamsForErrors has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static checkInnerParamsForErrors(domParentNode?: HTMLElement,
                                            objGridParams?: CGridParams,
                                            arrTiles?: Array<CTileParams>) {
        let isError = false;
        if (
Severity: Major
Found in src/ts/Modules/CSTiles.ts - About 2 hrs to fix

Function assignDefaultTileParams has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public static assignDefaultTileParams(objGridParams: CGridParams, arrTiles: Array<CTileParams>): any {
        /**
         * The enumeration of all tiles
         */
        let grid = [];
Severity: Minor
Found in src/ts/Modules/CSTiles.ts - About 2 hrs 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 optimizeCssProperty has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static optimizeCssProperty(strCssPropertyName, strCssPropertyValue): string {
        strCssPropertyValue = (" " + strCssPropertyValue + " ")
            .replace(/\s0%/ig, " 0")
            .replace(/[\r\n\t]/ig, " ")
            .replace(/\s+/ig, " ")
Severity: Minor
Found in src/ts/Modules/CSTiles.ts - About 1 hr to fix

Function assignDefaultTileParams has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static assignDefaultTileParams(objGridParams: CGridParams, arrTiles: Array<CTileParams>): any {
        /**
         * The enumeration of all tiles
         */
        let grid = [];
Severity: Minor
Found in src/ts/Modules/CSTiles.ts - About 1 hr to fix

Function convertCss has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static convertCss(arrCss: Object) {
        for (let strMedia in arrCss) {
            if (arrCss.hasOwnProperty(strMedia)) {
                for (let strBlockID in arrCss[strMedia]) {
                    if (arrCss[strMedia].hasOwnProperty(strBlockID)) {
Severity: Minor
Found in src/ts/Modules/CSTiles.ts - About 1 hr to fix

Function insertContentVideo has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static insertContentVideo(domParentNode: HTMLElement,
                                     objContent: any,
                                     arrCss: Object) {
        let domTileVideo = document.createElement("video");
        domTileVideo.id = CSTiles.getUUID();
Severity: Minor
Found in src/ts/Modules/CSTiles.ts - About 1 hr to fix

Function constructor has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    constructor(domParentNode?: HTMLElement,
                objGridParams?: CGridParams,
                arrTiles?: Array<CTileParams>) {
        /**
         * Assign default params
Severity: Minor
Found in src/ts/Modules/CSTiles.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 insertContentAudio has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static insertContentAudio(domParentNode: HTMLElement,
                                     objContent: any,
                                     arrCss: Object) {
        let domTileVideo = document.createElement("audio");
        domTileVideo.id = CSTiles.getUUID();
Severity: Minor
Found in src/ts/Modules/CSTiles.ts - About 1 hr to fix

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

    public static insertContentAudio(domParentNode: HTMLElement,
                                     objContent: any,
                                     arrCss: Object) {
        let domTileVideo = document.createElement("audio");
        domTileVideo.id = CSTiles.getUUID();
Severity: Minor
Found in src/ts/Modules/CSTiles.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 insertContentVideo has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public static insertContentVideo(domParentNode: HTMLElement,
                                     objContent: any,
                                     arrCss: Object) {
        let domTileVideo = document.createElement("video");
        domTileVideo.id = CSTiles.getUUID();
Severity: Minor
Found in src/ts/Modules/CSTiles.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 insertContent has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static insertContent(domParentNode: HTMLElement,
                                objContent: any,
                                arrCss: Object) {
        switch (objContent.type) {
            case "none":
Severity: Minor
Found in src/ts/Modules/CSTiles.ts - About 1 hr to fix

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

    public static checkInnerParamsForErrors(domParentNode?: HTMLElement,
                                            objGridParams?: CGridParams,
                                            arrTiles?: Array<CTileParams>) {
        let isError = false;
        if (
Severity: Minor
Found in src/ts/Modules/CSTiles.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

Avoid deeply nested control flow statements.
Open

                        if (r) {
                            adaptiveGrid[strMediaName] = r.grid;
                            arrTiles[objTileID].tileAdaptivePosition[strMediaName] = [r.x, r.y];
                        }
Severity: Major
Found in src/ts/Modules/CSTiles.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        for (let strCssProperty in arrCss[strMedia][strBlockID]) {
                            if (arrCss[strMedia][strBlockID].hasOwnProperty(strCssProperty)) {
                                arrCss[strMedia][strBlockID][strCssProperty] = CSTiles.optimizeCssProperty(strCssProperty, arrCss[strMedia][strBlockID][strCssProperty]);
                            }
                        }
Severity: Major
Found in src/ts/Modules/CSTiles.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (arrCss[strMedia].hasOwnProperty(strBlockID)) {
                            strCss += `#${strBlockID} {`;
                            for (let strCssProperty in arrCss[strMedia][strBlockID]) {
                                if (arrCss[strMedia][strBlockID].hasOwnProperty(strCssProperty)) {
                                    strCss += `${strCssProperty}: ${arrCss[strMedia][strBlockID][strCssProperty]} !important;`;
Severity: Major
Found in src/ts/Modules/CSTiles.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                if (
                    strCssPropertyValue[0] === strCssPropertyValue[1] &&
                    strCssPropertyValue[1] === strCssPropertyValue[2] &&
                    strCssPropertyValue[2] === strCssPropertyValue[3]
                ) {
Severity: Major
Found in src/ts/Modules/CSTiles.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (strCompiledRules) {
                            objCssProperties[strCompiledRule].push(strCompiledRules);
                        }
Severity: Major
Found in src/ts/Modules/CSTiles.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        for (let _strRule of arrRules) {
                            if (objCssProperties[_strRule]) {
                                arrCompiledRules.push(objCssProperties[_strRule]);
                                delete objCssProperties[_strRule];
                            }
Severity: Major
Found in src/ts/Modules/CSTiles.ts - About 45 mins to fix

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

    public static assignAdaptive(objObject: Object,
                                 arrAdaptiveMedia: Object,
                                 strPropertyFrom: string,
                                 strPropertyTo: string): any {
        objObject = objObject || {};
Severity: Minor
Found in src/ts/Modules/CSTiles.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

Avoid deeply nested control flow statements.
Open

                        if (isFunded) {
                            break;
                        }
Severity: Major
Found in src/ts/Modules/CSTiles.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        for (x = 0; x <= grid[y].length - tileSize[0]; x++) {
                            let ifGap = true;
                            for (i = y; i < y + tileSize[1]; i++) {
                                for (j = x; j < x + tileSize[0]; j++) {
                                    if (grid[i][j]) {
Severity: Major
Found in src/ts/Modules/CSTiles.ts - About 45 mins to fix

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

    public static isInstanceOf(objFirstObject: Object,
                               objSecondObject: Object): boolean {
        if (
            !(
                typeof objFirstObject === "object" &&
Severity: Minor
Found in src/ts/Modules/CSTiles.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

There are no issues that match your filters.

Category
Status