airbnb/caravel

View on GitHub
superset-frontend/src/middleware/asyncEvent.ts

Summary

Maintainability
B
4 hrs
Test Coverage

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

const wsConnect = (): void => {
  let url = config.GLOBAL_ASYNC_QUERIES_WEBSOCKET_URL;
  if (lastReceivedEventId) url += `?last_id=${lastReceivedEventId}`;
  ws = new WebSocket(url);

Severity: Minor
Found in superset-frontend/src/middleware/asyncEvent.ts - About 1 hr to fix

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

    export const processEvents = async (events: AsyncEvent[]) => {
      events.forEach((asyncEvent: AsyncEvent) => {
        const jobId = asyncEvent.job_id;
        const listener = listenersByJobId[jobId];
        if (listener) {
    Severity: Minor
    Found in superset-frontend/src/middleware/asyncEvent.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 waitForAsyncData has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export const waitForAsyncData = async (asyncResponse: AsyncEvent) =>
      new Promise((resolve, reject) => {
        const jobId = asyncResponse.job_id;
        const listener = async (asyncEvent: AsyncEvent) => {
          switch (asyncEvent.status) {
    Severity: Minor
    Found in superset-frontend/src/middleware/asyncEvent.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 loadEventsFromApi has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    const loadEventsFromApi = async () => {
      const eventArgs = lastReceivedEventId ? { last_id: lastReceivedEventId } : {};
      if (Object.keys(listenersByJobId).length) {
        try {
          const { result: events } = await fetchEvents(eventArgs);
    Severity: Minor
    Found in superset-frontend/src/middleware/asyncEvent.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 init has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    export const init = (appConfig?: AppConfig) => {
      if (!isFeatureEnabled(FeatureFlag.GlobalAsyncQueries)) return;
      if (pollingTimeoutId) clearTimeout(pollingTimeoutId);
    
      listenersByJobId = {};
    Severity: Minor
    Found in superset-frontend/src/middleware/asyncEvent.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

    There are no issues that match your filters.

    Category
    Status