CrazySquirrel/UniqueTransport

View on GitHub

Showing 65 of 96 total issues

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 preprocessor has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public preprocessor(request) {
    return new Promise((resolve, reject) => {
      const data = [];
      /**
       * Get data from url
Severity: Minor
Found in lib/ts/server.ts - About 1 hr 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 encodeSync has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  public encodeSync(data: any, password: string) {
    if (
        this.cryptoModule === "" ||
        this.cryptoModule === "base64salt"
    ) {
Severity: Minor
Found in lib/ts/server.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 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 redirectProxy has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        const redirectProxy = () => {
          if (
              result.Data.link.indexOf(".css") === -1 &&
              result.Data.link.indexOf("yandex") === -1
          ) {
Severity: Minor
Found in lib/ts/server.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 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 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

Function decodeSync has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public decodeSync(data: any, password: string) {
    try {
      let dec = decodeURIComponent(global.escape(Buffer.from(data, "base64").toString("utf8"))).split("@");
      dec.shift();
      dec = JSON.parse(dec.join("@"));
Severity: Minor
Found in lib/ts/server.ts - About 1 hr to fix

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

  public listenr(request, response) {
    this.AcceptEncoding = request.headers["accept-encoding"] || "";

    const headers = Object.assign({}, baseHeaders);

Severity: Minor
Found in lib/ts/server.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 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 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

Function responceError has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public responceError(id, request, response, headers, e?, ...data) {
    this.ErrorHandler(e, id, data);

    if (request.headers["x-real-404"]) {
      const url = URL.parse(request.headers["x-real-404"]);
Severity: Minor
Found in lib/ts/server.ts - About 1 hr to fix

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

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 (
                    this.listners["proxy"]
                ) {
                  new Promise(
                      (_resolve) => {
Severity: Major
Found in lib/ts/server.ts - About 45 mins to fix
Severity
Category
Status
Source
Language