Thorin0ak/rn-eventsource-mercure

View on GitHub

Showing 8 of 17 total issues

Function constructor has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  constructor(url: string, eventSourceInitDict: ?Object) {
    super();

    if (!url) {
      throw new Error('Cannot open an SSE stream on an empty url');
Severity: Minor
Found in src/EventSource.js - About 2 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 __processEventStreamChunk has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  __processEventStreamChunk(chunk: string): void {
    if (this._isFirstChunk) {
      if (
        bom.every((charCode, idx) => {
          return this._lineBuf.charCodeAt(idx) === charCode;
Severity: Minor
Found in src/EventSource.js - 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 __didReceiveResponse has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  __didReceiveResponse(
    requestId: number,
    status: number,
    responseHeaders: ?Object,
    responseURL: ?string,
Severity: Minor
Found in src/EventSource.js - 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 sendRequest has 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

        method,
        _,
        url,
        headers,
        __,
Severity: Major
Found in src/__tests__/EventSource-test.js - About 1 hr to fix

    Function __processEventStreamChunk has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      __processEventStreamChunk(chunk: string): void {
        if (this._isFirstChunk) {
          if (
            bom.every((charCode, idx) => {
              return this._lineBuf.charCodeAt(idx) === charCode;
    Severity: Minor
    Found in src/EventSource.js - About 1 hr to fix

      Function __processEventStreamLine has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        __processEventStreamLine(): void {
          const line = this._lineBuf;
      
          // clear the line buffer
          this._lineBuf = '';
      Severity: Minor
      Found in src/EventSource.js - 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

      Avoid too many return statements within this function.
      Open

            return this.close();
      Severity: Major
      Found in src/EventSource.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return this.close();
        Severity: Major
        Found in src/EventSource.js - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language