cyclejs/cycle-core

View on GitHub
state/src/Collection.ts

Summary

Maintainability
D
2 days
Test Coverage

Function makeCollection has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

export function makeCollection<S, So = any, Si = any>(
  opts: CollectionOptions<S, So, Si>
) {
  return function collectionComponent(sources: any) {
    const name = opts.channel || 'state';
Severity: Minor
Found in state/src/Collection.ts - About 7 hrs 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 makeCollection has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function makeCollection<S, So = any, Si = any>(
  opts: CollectionOptions<S, So, Si>
) {
  return function collectionComponent(sources: any) {
    const name = opts.channel || 'state';
Severity: Major
Found in state/src/Collection.ts - About 2 hrs to fix

    Function collectionComponent has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      return function collectionComponent(sources: any) {
        const name = opts.channel || 'state';
        const itemKey = opts.itemKey;
        const itemScope = opts.itemScope || defaultItemScope;
        const state$ = xs.fromObservable((sources[name] as StateSource<S>).stream);
    Severity: Major
    Found in state/src/Collection.ts - About 2 hrs to fix

      Function instances$ has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            (acc: InternalInstances<Si>, nextState: Array<any> | any) => {
              const dict = acc.dict;
              if (Array.isArray(nextState)) {
                const nextInstArray = Array(nextState.length) as Array<
                  Si & {_key: string}
      Severity: Minor
      Found in state/src/Collection.ts - About 2 hrs to fix

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

        function instanceLens(
          itemKey: ItemKeyFn<any>,
          key: string
        ): Lens<Array<any>, any> {
          return {
        Severity: Minor
        Found in state/src/Collection.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 instanceLens has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function instanceLens(
          itemKey: ItemKeyFn<any>,
          key: string
        ): Lens<Array<any>, any> {
          return {
        Severity: Minor
        Found in state/src/Collection.ts - About 1 hr to fix

          There are no issues that match your filters.

          Category
          Status