tdreyno/figment

View on GitHub

Showing 22 of 22 total issues

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

export const contramap = <A, B, C>(cToA: (c: C) => A) => (
reader: Reader<A, B>,
): Reader<C, B> => pipe(cToA, reader)
Severity: Major
Found in src/monads/Reader.ts and 1 other location - About 2 hrs to fix
src/monads/Reader.ts on lines 7..9

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

export const map = <A, B, C>(bToC: (b: B) => C) => (
reader: Reader<A, B>,
): Reader<A, C> => pipe(reader, bToC)
Severity: Major
Found in src/monads/Reader.ts and 1 other location - About 2 hrs to fix
src/monads/Reader.ts on lines 11..13

Function set has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

const set = <T>(args: any[], value: T) => (cache: CacheObj<T>): void => {
let previousNode = cache.root
 
// tslint:disable-next-line: prefer-for-of
for (let i = 0; i < args.length; i++) {
Severity: Minor
Found in src/memo/index.ts - About 1 hr to fix

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

function unbrand<K, V>(branded: TreeNode<K, V>): UnbrandedTreeNode<K, V> {
return (branded as unknown) as UnbrandedTreeNode<K, V>
}
Severity: Major
Found in src/memo/TreeNode.ts and 1 other location - About 1 hr to fix
src/memo/TreeNode.ts on lines 13..15

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

function brand<K, V>(unbranded: UnbrandedTreeNode<K, V>): TreeNode<K, V> {
return (unbranded as unknown) as TreeNode<K, V>
}
Severity: Major
Found in src/memo/TreeNode.ts and 1 other location - About 1 hr to fix
src/memo/TreeNode.ts on lines 17..19

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

export const isRight = <A, B>(either: Either<A, B>): either is Right<B> =>
either.type === "Right"
Severity: Major
Found in src/monads/Either.ts and 1 other location - About 1 hr to fix
src/monads/Either.ts on lines 56..57

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

export const isLeft = <A, B>(either: Either<A, B>): either is Left<A> =>
either.type === "Left"
Severity: Major
Found in src/monads/Either.ts and 1 other location - About 1 hr to fix
src/monads/Either.ts on lines 59..60

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

export const isOk = <A, B>(result: Result<A, B>): result is Ok<B> =>
isRight(result)
Severity: Major
Found in src/monads/Result.ts and 1 other location - About 1 hr to fix
src/monads/Result.ts on lines 53..54

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

export const isError = <A, B>(result: Result<A, B>): result is Err<A> =>
isLeft(result)
Severity: Major
Found in src/monads/Result.ts and 1 other location - About 1 hr to fix
src/monads/Result.ts on lines 50..51

Function filter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export const filter = <A>(fn: (a: A) => unknown) => (list: List<A>): List<A> =>
let_<[A | Nil, List<A>], List<A>>((h, t) =>
isNil(h) ? Nil : fn(h) ? [h, filter(fn)(t)] : filter(fn)(t),
)(head(list), tail(list))
Severity: Minor
Found in src/list/List.ts - About 55 mins to fix

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

export const Left = <A, B = unknown>(value: A): Either<A, B> => ({
type: "Left",
value,
})
Severity: Minor
Found in src/monads/Either.ts and 1 other location - About 55 mins to fix
src/monads/Either.ts on lines 20..23

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

export const Right = <B, A = unknown>(value: B): Either<A, B> => ({
type: "Right",
value,
})
Severity: Minor
Found in src/monads/Either.ts and 1 other location - About 55 mins to fix
src/monads/Either.ts on lines 15..18

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

export const isNothing = <T>(maybe: Maybe<T>): maybe is Nothing<T> =>
isLeft(maybe)
Severity: Minor
Found in src/monads/Maybe.ts and 1 other location - About 50 mins to fix
src/monads/Maybe.ts on lines 53..53

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

export const isJust = <T>(maybe: Maybe<T>): maybe is Just<T> => isRight(maybe)
Severity: Minor
Found in src/monads/Maybe.ts and 1 other location - About 50 mins to fix
src/monads/Maybe.ts on lines 55..56

Function every has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const every = <A>(fn: (a: A) => unknown) => (list: List<A>): boolean =>
let_<[A | Nil, List<A>], boolean>((h, t) =>
isNil(h) ? true : !fn(h) ? false : every(fn)(t),
)(head(list), tail(list))
Severity: Minor
Found in src/list/List.ts - About 45 mins to fix

Function some has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const some = <A>(fn: (a: A) => unknown) => (list: List<A>): boolean =>
let_<[A | Nil, List<A>], boolean>((h, t) =>
isNil(h) ? false : fn(h) ? true : some(fn)(t),
)(head(list), tail(list))
Severity: Minor
Found in src/list/List.ts - About 45 mins to fix

Function and has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const and = <Args extends any[]>(
...options: Array<((...args: Args) => unknown) | unknown>
) => (...args: Args): boolean =>
options.every(fnOrBool =>
isFunction(fnOrBool)
Severity: Minor
Found in src/core/index.ts - About 45 mins to fix

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

export const cata = <A, B, U>(handlers: {
Err: (a: A) => U
Ok: (v: B) => U
}) =>
cata_({
Severity: Minor
Found in src/monads/Result.ts and 1 other location - About 40 mins to fix
src/monads/Either.ts on lines 25..36

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

export const cata = <A, B, R>(handlers: {
Left: (v: A) => R
Right: (v: B) => R
}) => (either: Either<A, B>): R => {
switch (either.type) {
Severity: Minor
Found in src/monads/Either.ts and 1 other location - About 40 mins to fix
src/monads/Result.ts on lines 23..30

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

export const Err = <A, B = unknown>(value: A): Result<A, B> => Left(value)
Severity: Minor
Found in src/monads/Result.ts and 1 other location - About 35 mins to fix
src/monads/Result.ts on lines 18..18
Severity
Category
Status
Source
Language