tdreyno/pretty-please

View on GitHub

Showing 28 of 32 total issues

Task has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

export class Task<E, S> implements PromiseLike<S> {
public static fail = fail
public static succeed = succeed
public static empty = empty
public static failIn = failIn
Severity: Minor
Found in src/Task/Task.ts - About 3 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    const triggerReject = (error: E) => {
    state = "failure"
    cachedError = error
     
    Object.keys(callbacks).forEach(id => {
    Severity: Major
    Found in src/Task/Task.ts and 1 other location - About 2 hrs to fix
    src/Task/Task.ts on lines 167..175

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    const triggerResolve = (result: S) => {
    state = "success"
    cachedResult = result
     
    Object.keys(callbacks).forEach(id => {
    Severity: Major
    Found in src/Task/Task.ts and 1 other location - About 2 hrs to fix
    src/Task/Task.ts on lines 157..165

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    public append<A, B, C, D, E>(
    a: A,
    b: B,
    c: C,
    d: D,
    Severity: Major
    Found in src/Task/Task.ts and 1 other location - About 2 hrs to fix
    src/Task/Task.ts on lines 913..919

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    public prepend<A, B, C, D, E>(
    a: A,
    b: B,
    c: C,
    d: D,
    Severity: Major
    Found in src/Task/Task.ts and 1 other location - About 2 hrs to fix
    src/Task/Task.ts on lines 898..904

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    public validate<E2, S2>(
    fn: (value: S) => Validation<E2, S2>,
    ): Task<E | E2, S2> {
    return validate(fn, this)
    }
    Severity: Major
    Found in src/Task/Task.ts and 1 other location - About 1 hr to fix
    src/Task/Task.ts on lines 870..872

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    public chain<E2, S2>(fn: (result: S) => Task<E2, S2>): Task<E | E2, S2> {
    return chain(fn, this)
    }
    Severity: Major
    Found in src/Task/Task.ts and 1 other location - About 1 hr to fix
    src/Task/Task.ts on lines 936..940

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    public append<A, B, C, D>(a: A, b: B, c: C, d: D): Task<E, [S, A, B, C, D]>
    Severity: Major
    Found in src/Task/Task.ts and 1 other location - About 1 hr to fix
    src/Task/Task.ts on lines 920..920

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    public prepend<A, B, C, D>(a: A, b: B, c: C, d: D): Task<E, [A, B, C, D, S]>
    Severity: Major
    Found in src/Task/Task.ts and 1 other location - About 1 hr to fix
    src/Task/Task.ts on lines 905..905

    Function sequence has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    new Task((reject, resolve) => {
    let isDone = false
     
    type TaskPosition = [Task<E, S>, number]
     
     
    Severity: Minor
    Found in src/Task/Task.ts - About 1 hr to fix

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

      export const ap = <E, S, S2>(
      task: Task<E, (result: S) => S2>,
      appliedTask: Task<E, S>,
      ): Task<E, S2> =>
      new Task((reject, resolve) => {
      Severity: Minor
      Found in src/Task/Task.ts - About 1 hr to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      public reject(error: E): void {
      this.alreadyError_ = error
      this.lastState_ = "error"
       
      if (this.computationReject_) {
      Severity: Major
      Found in src/Task/Task.ts and 1 other location - About 1 hr to fix
      src/Task/Task.ts on lines 1039..1046

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      public resolve(result: S): void {
      this.alreadyResult_ = result
      this.lastState_ = "success"
       
      if (this.computationResolve_) {
      Severity: Major
      Found in src/Task/Task.ts and 1 other location - About 1 hr to fix
      src/Task/Task.ts on lines 1030..1037

      Function enqueue has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const enqueue = () => {
      if (isDone) {
      return
      }
       
       
      Severity: Minor
      Found in src/Task/Task.ts - About 1 hr to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        public append<A, B, C>(a: A, b: B, c: C): Task<E, [S, A, B, C]>
        Severity: Major
        Found in src/Task/Task.ts and 1 other location - About 1 hr to fix
        src/Task/Task.ts on lines 921..921

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        public prepend<A, B, C>(a: A, b: B, c: C): Task<E, [A, B, C, S]>
        Severity: Major
        Found in src/Task/Task.ts and 1 other location - About 1 hr to fix
        src/Task/Task.ts on lines 906..906

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        export const mapBoth = <E, S, E2, S2>(
        handleError: (error: E) => E2,
        handleSuccess: (success: S) => S2,
        task: Task<E, S>,
        ): Task<E2, S2> => mapError(handleError, map(handleSuccess, task))
        Severity: Major
        Found in src/Task/Task.ts and 1 other location - About 1 hr to fix
        src/Task/Task.ts on lines 655..665

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        export const fold = <E, S, R>(
        handleError: (error: E) => R,
        handleSuccess: (success: S) => R,
        task: Task<E, S>,
        ): Task<never, R> =>
        Severity: Major
        Found in src/Task/Task.ts and 1 other location - About 1 hr to fix
        src/Task/Task.ts on lines 643..647

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        public mapError<E2>(fn: (error: E) => E2): Task<E2, S> {
        return mapError(fn, this)
        }
        Severity: Minor
        Found in src/Task/Task.ts and 1 other location - About 55 mins to fix
        src/Task/Task.ts on lines 890..892

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        public map<S2>(fn: (result: S) => S2): Task<E, S2> {
        return map(fn, this)
        }
        Severity: Minor
        Found in src/Task/Task.ts and 1 other location - About 55 mins to fix
        src/Task/Task.ts on lines 942..944
        Severity
        Category
        Status
        Source
        Language