Showing 4 of 37 total issues
Function useWorkflow
has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring. Open
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 = {}
- 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 useWorkflow
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
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 = {}
File state.test.ts
has 319 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { useState } from "./state"
import { State, LitLikeElement, InjectableState } from "./types"
import { asUpdateableLitElement } from "./decorator"
class StateExample { constructor(public value = "true") {} }
Function customersReducer
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
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[])
- 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"