Function checkV3ParticipantStates
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const checkV3ParticipantStates = (channel: ChannelTypes, selectedForce: string | undefined, selectedRole: Role['roleId'], isObserver: boolean): CheckParticipantStates => {
if (selectedForce === undefined) throw new Error('selectedForce is undefined')
const channelParts: CoreParticipant[] = channel.participants
const participatingForce: CoreParticipant | undefined = channelParts && channelParts.find(p => matchedForceFilter(p.forceUniqid, selectedForce))
// not a member of this channel, return false answer
Function getParticipantStates
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const getParticipantStates = (
channel: ChannelTypes, forceId: string | undefined,
role: Role['roleId'], isObserver: boolean,
allTemplatesByKey: TemplateBodysByKey,
// TODO: move it to reducer, for future default Message can be changed from admin
Function setTemplatesBasedOnConditions
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export const setTemplatesBasedOnConditions = (
chosenTemplates: TemplateBody[],
chatTemplate: TemplateBody | undefined,
allTemplatesByKey: TemplateBodysByKey
): TemplateBody[] => {
- 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 checkV3ParticipantStates
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
export const checkV3ParticipantStates = (channel: ChannelTypes, selectedForce: string | undefined, selectedRole: Role['roleId'], isObserver: boolean): CheckParticipantStates => {
if (selectedForce === undefined) throw new Error('selectedForce is undefined')
const channelParts: CoreParticipant[] = channel.participants
const participatingForce: CoreParticipant | undefined = channelParts && channelParts.find(p => matchedForceFilter(p.forceUniqid, selectedForce))
// not a member of this channel, return false answer
- 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 getParticipantStates
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export const getParticipantStates = (
channel: ChannelTypes, forceId: string | undefined,
role: Role['roleId'], isObserver: boolean,
allTemplatesByKey: TemplateBodysByKey,
// TODO: move it to reducer, for future default Message can be changed from admin
- 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 addTemplatesToChosen
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export const addTemplatesToChosen = (
templatesIDs: ParticipantTemplate[] | undefined,
allTemplatesByKey: TemplateBodysByKey,
chosenTemplates: TemplateBody[],
templatesUniqFilter: { [property: string]: boolean }
- 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"