Showing 10 of 103 total issues
File use-observable-get-state.ts
has 357 lines of code (exceeds 250 allowed). Consider refactoring. Open
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";
File concurrent-mode.spec.tsx
has 281 lines of code (exceeds 250 allowed). Consider refactoring. Open
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;
Function useObservableEagerState
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function useObservableEagerState<TState>(
state$: Observable<TState>
): TState {
const forceUpdate = useForceUpdate();
Function constructor
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
Open
public constructor(
input$: Observable<TInput>,
isSuccess?: TInput extends TOutput
? (value: TInput) => boolean
: (value: TInput) => value is TOutput
- Read upRead up
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
Open
public constructor(
input$: Observable<TInput>,
isSuccess?: TInput extends TOutput
? (value: TInput) => boolean
: (value: TInput) => value is TOutput
Function useSubscriptionInternal
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function useSubscriptionInternal<TInput>(
useCustomEffect: typeof useEffect,
args: Args<TInput>
): MutableRefObject<Subscription | undefined> {
const argsRef = useRef(args);
Function ObservableValueDescendant
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
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.
Function fakePostsXHR
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function fakePostsXHR(id: string): Promise<Posts> {
console.log("fetch post...");
await timer(3000 * Math.random());
console.log("fetched post");
switch (id) {
Function useObservableStateInternal
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
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 `;
- Read upRead up
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"