CrazySquirrel/UniqueTransport

View on GitHub
lib/ts/client.ts

Summary

Maintainability
F
5 days
Test Coverage

File client.ts has 668 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

Function styleadvanced has 90 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public styleadvanced(params: any = {}) {
    return new Promise((resolve, reject) => {
      const onerror = () => {
        try {
          link.href = "";
Severity: Major
Found in lib/ts/client.ts - About 3 hrs to fix

Function emit has 85 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public emit(params: any = {}) {
    params.Event = params.Event || "";
    params.Data = params.Data || {};
    params.Debug = params.Debug || false;

Severity: Major
Found in lib/ts/client.ts - About 3 hrs to fix

Function generateChoises has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  public generateChoises() {
    const choices = {
      bad: {},
      good: {},
      normal: {},
Severity: Minor
Found in lib/ts/client.ts - About 3 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 styleextend has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public styleextend(params: any = {}) {
    return new Promise((resolve, reject) => {
      const onerror = () => {
        try {
          link.href = "";
Severity: Major
Found in lib/ts/client.ts - About 2 hrs to fix

Function onload has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      const onload = () => {
        if (
            link.sheet &&
            link.sheet.cssRules.length > 0
        ) {
Severity: Major
Found in lib/ts/client.ts - About 2 hrs to fix

Function style has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public style(params: any = {}) {
    return new Promise((resolve, reject) => {
      const onerror = () => {
        try {
          link.href = "";
Severity: Major
Found in lib/ts/client.ts - About 2 hrs to fix

Function xhr has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public xhr(params: any = {}) {
    return new Promise((resolve, reject) => {
      let xhr;

      const onerror = () => {
Severity: Minor
Found in lib/ts/client.ts - About 2 hrs to fix

Function fetch has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public fetch(params: any = {}) {
    return new Promise((resolve, reject) => {
      const onerror = () => {
        reject();
      };
Severity: Minor
Found in lib/ts/client.ts - About 1 hr to fix

Function generateChoises has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public generateChoises() {
    const choices = {
      bad: {},
      good: {},
      normal: {},
Severity: Minor
Found in lib/ts/client.ts - About 1 hr to fix

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

  public script(params: any = {}) {
    return new Promise((resolve, reject) => {
      const onerror = () => {
        try {
          script.src = "";
Severity: Minor
Found in lib/ts/client.ts - About 1 hr to fix

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

  public iframe(params: any = {}) {
    return new Promise((resolve, reject) => {
      const onerror = () => {
        try {
          iframe.src = "";
Severity: Minor
Found in lib/ts/client.ts - About 1 hr to fix

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

  public static cleanOldChoises() {
    try {
      for (let major = 1; major < 3; major++) {
        for (let minor = 0; minor < 10; minor++) {
          for (let patch = 0; patch < 100; patch++) {
Severity: Minor
Found in lib/ts/client.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 onload has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      const onload = () => {
        if (
            link.sheet &&
            link.sheet.cssRules.length > 0
        ) {
Severity: Minor
Found in lib/ts/client.ts - About 1 hr to fix

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

  public filterChoises() {
    const _choices = this.generateChoises();

    const choices = {
      bad: {},
Severity: Minor
Found in lib/ts/client.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 (rules) {
                  for (let i = 0; i < rules.length; i++) {
                    const rule = rules[i].split(":");
                    rule[1] = rule[1].match(/[0-9]*/ig).filter((v) => v !== "");
                    if (
Severity: Major
Found in lib/ts/client.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                if (_data) {
                  return resolve(_data);
                }
Severity: Major
Found in lib/ts/client.ts - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

            for (let i3 = 0; i3 < HttpMethodsKeys.length; i3++) {
              const HttpMethod = HttpMethodsKeys[i3];

              if (
                  ["GET", "POST", "PUT", "PATCH"].indexOf(HttpMethod) !== -1
Severity: Major
Found in lib/ts/client.ts - About 45 mins to fix

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

  public generateSubtransportChoices(choices: any, obj: any, subtransports: any): void {
    const l = subtransports.length;
    if (l) {
      for (let x = 0; x < l; x++) {
        if (
Severity: Minor
Found in lib/ts/client.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

TODO found
Open

     //TODO: add logger
Severity: Minor
Found in lib/ts/client.ts by fixme

TODO found
Open

     //TODO: add logger
Severity: Minor
Found in lib/ts/client.ts by fixme

TODO found
Open

     //TODO: add logger
Severity: Minor
Found in lib/ts/client.ts by fixme

TODO found
Open

     //TODO: add logger
Severity: Minor
Found in lib/ts/client.ts by fixme

TODO found
Open

     //TODO: add logger
Severity: Minor
Found in lib/ts/client.ts by fixme

TODO found
Open

     //TODO: add logger
Severity: Minor
Found in lib/ts/client.ts by fixme

TODO found
Open

        //TODO: add logger
Severity: Minor
Found in lib/ts/client.ts by fixme

TODO found
Open

     //TODO: add logger
Severity: Minor
Found in lib/ts/client.ts by fixme

TODO found
Open

      //TODO: add logger
Severity: Minor
Found in lib/ts/client.ts by fixme

TODO found
Open

     //TODO: add logger
Severity: Minor
Found in lib/ts/client.ts by fixme

There are no issues that match your filters.

Category
Status