CrazySquirrel/CSLogger

View on GitHub
lib/CSLogger.ts

Summary

Maintainability
C
1 day
Test Coverage

Function watch has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public static watch() {
    if (CSLogger.arrLog.length > 0 && CSLogger.arrLog.length < 100) {
      for (let j = 0; j < CSLogger.arrLog.length; j++) {
        const l = CSLogger.arrLog[j];
        const data = encodeURIComponent(JSON.stringify(l));
Severity: Minor
Found in lib/CSLogger.ts - About 1 hr to fix

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

  public static watch() {
    if (CSLogger.arrLog.length > 0 && CSLogger.arrLog.length < 100) {
      for (let j = 0; j < CSLogger.arrLog.length; j++) {
        const l = CSLogger.arrLog[j];
        const data = encodeURIComponent(JSON.stringify(l));
Severity: Minor
Found in lib/CSLogger.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 status === "number" &&
        status > 0 &&
        typeof message === "string" &&
        message.length > 0
Severity: Critical
Found in lib/CSLogger.ts - About 1 hr to fix

Function showMessange has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public static showMessange(status: number, message: string): boolean {
    if (
        typeof status === "number" &&
        status > 0 &&
        typeof message === "string" &&
Severity: Minor
Found in lib/CSLogger.ts - About 1 hr to fix

Function log has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public static log(status?: number,
                    message?: string,
                    properties?: any): boolean {
    if (
        typeof status === "number" &&
Severity: Minor
Found in lib/CSLogger.ts - About 1 hr to fix

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

  public static init(settings) {
    if (typeof settings === "object") {
      for (const prop in settings) {
        if (settings.hasOwnProperty(prop)) {
          CSLogger.settings[prop] = settings[prop];
Severity: Minor
Found in lib/CSLogger.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

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

  public static statusLavelSentry(status: number): string {
    if (
        typeof status === "number" &&
        status > 0
    ) {
Severity: Minor
Found in lib/CSLogger.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

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

  public static statusLavelConsole(status: number): string {
    if (
        typeof status === "number" &&
        status > 0
    ) {
Severity: Minor
Found in lib/CSLogger.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 "";
Severity: Major
Found in lib/CSLogger.ts - About 30 mins to fix

Avoid too many return statements within this function.
Open

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

Avoid too many return statements within this function.
Open

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

Avoid too many return statements within this function.
Open

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

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

  public static showMessange(status: number, message: string): boolean {
    if (
        typeof status === "number" &&
        status > 0 &&
        typeof message === "string" &&
Severity: Minor
Found in lib/CSLogger.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

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

  public static log(status?: number,
                    message?: string,
                    properties?: any): boolean {
    if (
        typeof status === "number" &&
Severity: Minor
Found in lib/CSLogger.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

There are no issues that match your filters.

Category
Status