serge-web/serge-web

View on GitHub
client/src/Helpers/participant-states.ts

Summary

Maintainability
B
4 hrs
Test Coverage

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
Severity: Minor
Found in client/src/Helpers/participant-states.ts - About 1 hr to fix

    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
    Severity: Minor
    Found in client/src/Helpers/participant-states.ts - About 1 hr to fix

      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[] => {
      Severity: Minor
      Found in client/src/Helpers/participant-states.ts - About 45 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

      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
      Severity: Minor
      Found in client/src/Helpers/participant-states.ts - About 35 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

      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
      Severity: Minor
      Found in client/src/Helpers/participant-states.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

      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 }
      Severity: Minor
      Found in client/src/Helpers/participant-states.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

      There are no issues that match your filters.

      Category
      Status