CrazySquirrel/UniqueTransport

View on GitHub

Showing 65 of 96 total issues

Avoid deeply nested control flow statements.
Open

                          if (e) {
                            doRedirect();
                          } else {
                            response.writeHead(this.Settings.SuccessResponseCode, JSON.parse(_headers));
                            FS.createReadStream(CachePathBody).pipe(response);
Severity: Major
Found in lib/ts/server.ts - About 45 mins 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 (!response.answered) {
                        response.answered = true;
                        FS.readFile(CachePathHeaders, "utf-8", (e, _headers) => {
                          try {
                            if (e) {
Severity: Major
Found in lib/ts/server.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

Avoid deeply nested control flow statements.
Open

                          if (
                              this.Settings.MaxProxySize &&
                              res.headers["content-length"] &&
                              parseInt(res.headers["content-length"], 10) > this.Settings.MaxProxySize &&
                              result.Data.link.indexOf(".css") === -1 &&
Severity: Major
Found in lib/ts/server.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

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

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

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

  public getHostFromHeaderXRealHost(request, params) {
    if (request.headers["x-real-host"]) {
      let origin;

      if (request.headers["x-real-host"].indexOf("http") === -1) {
Severity: Minor
Found in lib/ts/server.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

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 data;
Severity: Major
Found in lib/ts/server.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return null;
Severity: Major
Found in lib/ts/server.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 dec;
Severity: Major
Found in lib/ts/server.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return false;
Severity: Major
Found in lib/ts/server.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

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

  public getHostFromHeaderOrigin(request, params) {
    if (request.headers.origin) {
      let origin;

      if (request.headers.origin.indexOf("http") === -1) {
Severity: Minor
Found in lib/ts/server.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

Severity
Category
Status
Source
Language