MatthiasKainer/lit-element-state-decoupler

View on GitHub

Showing 4 of 37 total issues

Function useWorkflow has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

export const useWorkflow = (element: LitLikeElement, reducers: { [key: string]: {reducer: Reducer<any>, initialState: unknown} }): Workflow => {
    const innerReducers = Object.entries(reducers).reduce((prev, [projection, {reducer, initialState}]) =>
        (prev[projection] = useReducer(element, reducer, initialState), prev)
        , {} as InnerReducers)
    const sideeffect: Sideeffects = {}
Severity: Minor
Found in workflow.ts - About 5 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 useWorkflow has 100 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const useWorkflow = (element: LitLikeElement, reducers: { [key: string]: {reducer: Reducer<any>, initialState: unknown} }): Workflow => {
    const innerReducers = Object.entries(reducers).reduce((prev, [projection, {reducer, initialState}]) =>
        (prev[projection] = useReducer(element, reducer, initialState), prev)
        , {} as InnerReducers)
    const sideeffect: Sideeffects = {}
Severity: Major
Found in workflow.ts - About 4 hrs to fix

    File state.test.ts has 319 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { useState } from "./state"
    import { State, LitLikeElement, InjectableState } from "./types"
    import { asUpdateableLitElement } from "./decorator"
    
    class StateExample { constructor(public value = "true") {} }
    Severity: Minor
    Found in state.test.ts - About 3 hrs to fix

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

      const customersReducer: Reducer<Customer[]> = (state: Customer[]) => ({
          createCustomer: (userName: string) => {
              return new Promise((resolve, reject) => {
                  if (state.some(customer => customer.userName === userName)) return reject(conflict("User", state));
                  return resolve([...state, { userName }] as Customer[])
      Severity: Minor
      Found in workflow.test.ts - 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