CrazySquirrel/UniqueTransport

View on GitHub
lib/ts/transport.ts

Summary

Maintainability
D
2 days
Test Coverage

File transport.ts has 441 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";

/**
 * Import interfaces
 */
Severity: Minor
Found in lib/ts/transport.ts - About 6 hrs to fix

Function getChoiseType has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  public static getChoiseType(rate: any, choices: any): string {
    if (rate === 0) {
      if (Transport.isObjectNotEmpty(choices.normal)) {
        return "normal";
      } else if (Transport.isObjectNotEmpty(choices.bad)) {
Severity: Minor
Found in lib/ts/transport.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 combineSettings has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  public static combineSettings(settedSettings: any, defaultSettings: any): any {
    let settings;
    if (
        (
            typeof settedSettings === "boolean" ||
Severity: Minor
Found in lib/ts/transport.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

Consider simplifying this complex logical expression.
Open

    if (
        (
            typeof settedSettings === "boolean" ||
            typeof settedSettings === "number" ||
            typeof settedSettings === "string" ||
Severity: Critical
Found in lib/ts/transport.ts - About 1 hr to fix

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

  public getTransport(_transports: string[], type: string): string[] {
    /**
     * Filter sub transports by settings
     */
    const transports = [];
Severity: Minor
Found in lib/ts/transport.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 combineSettings has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public static combineSettings(settedSettings: any, defaultSettings: any): any {
    let settings;
    if (
        (
            typeof settedSettings === "boolean" ||
Severity: Minor
Found in lib/ts/transport.ts - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

      if (
          type === "base" ||
          (
              this.Settings &&
              this.Settings.Transports &&
Severity: Major
Found in lib/ts/transport.ts - About 40 mins to fix

Avoid too many return statements within this function.
Open

        return "good";
Severity: Major
Found in lib/ts/transport.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return "good";
Severity: Major
Found in lib/ts/transport.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return "normal";
Severity: Major
Found in lib/ts/transport.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return "bad";
Severity: Major
Found in lib/ts/transport.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

        return "normal";
Severity: Major
Found in lib/ts/transport.ts - About 30 mins to fix

There are no issues that match your filters.

Category
Status