crimx/observable-hooks

View on GitHub

Showing 10 of 103 total issues

File use-observable-get-state.ts has 357 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { useDebugValue } from "react";
import { Observable } from "rxjs";
import { map } from "rxjs/operators";
import { useObservableState } from "./use-observable-state";
import { useObservable } from "./use-observable";
Severity: Minor
Found in packages/observable-hooks/src/use-observable-get-state.ts - About 4 hrs to fix

    File concurrent-mode.spec.tsx has 281 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable @typescript-eslint/no-unsafe-assignment */
    /* eslint-disable @typescript-eslint/no-unsafe-return */
    import * as RxType from "rxjs";
    
    let Scheduler: import("./utils").Scheduler;
    Severity: Minor
    Found in packages/observable-hooks/__tests__/concurrent-mode.spec.tsx - About 2 hrs to fix

      Function useObservableEagerState has 65 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function useObservableEagerState<TState>(
        state$: Observable<TState>
      ): TState {
        const forceUpdate = useForceUpdate();
      
      
      Severity: Major
      Found in packages/observable-hooks/src/use-observable-eager-state.ts - About 2 hrs to fix

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

          public constructor(
            input$: Observable<TInput>,
            isSuccess?: TInput extends TOutput
              ? (value: TInput) => boolean
              : (value: TInput) => value is TOutput
        Severity: Minor
        Found in packages/observable-hooks/src/observable-resource.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 constructor has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public constructor(
            input$: Observable<TInput>,
            isSuccess?: TInput extends TOutput
              ? (value: TInput) => boolean
              : (value: TInput) => value is TOutput
        Severity: Minor
        Found in packages/observable-hooks/src/observable-resource.ts - About 1 hr to fix

          Function useSubscriptionInternal has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function useSubscriptionInternal<TInput>(
            useCustomEffect: typeof useEffect,
            args: Args<TInput>
          ): MutableRefObject<Subscription | undefined> {
            const argsRef = useRef(args);
          Severity: Minor
          Found in packages/observable-hooks/src/internal/use-subscription-internal.ts - About 1 hr to fix

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

            export const ObservableValueDescendant = () => {
              const num$ = useContext(ObservableValueContext);
            
              // If you need to transform(pipe) the Observable
              // you should list it as dependency since it may change over time.
            Severity: Minor
            Found in examples/context/src/ObservableValue.tsx - About 1 hr to fix

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

              async function fakePostsXHR(id: string): Promise<Posts> {
                console.log("fetch post...");
                await timer(3000 * Math.random());
                console.log("fetched post");
                switch (id) {
              Severity: Minor
              Found in examples/suspense/src/fakeApi.ts - About 1 hr to fix

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

                export function useObservableStateInternal<TState, TInput = TState>(
                  useSubscription: typeof useSubscriptionType,
                  state$OrInit:
                    | Observable<TState>
                    | ((

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

                  function fromNow(diff: number): string {
                    const minute = (diff / 60) | 0;
                    const second = diff - minute * 60;
                    const mstr =
                      minute < 1 ? "" : minute === 1 ? `a minute and ` : `${minute} minutes and `;
                  Severity: Minor
                  Found in examples/typeahead/src/input-time-ago.tsx - 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