Anapher/Strive

View on GitHub

Showing 735 of 735 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

export const selectMessagesError = (state: RootState, channel: string) =>
   state.chat.channels?.[channel]?.viewModel?.messagesError;
Severity: Minor
Found in src/Web/WebSPA/Client/src/features/chat/selectors.ts and 2 other locations - About 30 mins to fix
src/Web/WebSPA/Client/src/features/chat/selectors.ts on lines 14..15
src/Web/WebSPA/Client/src/features/chat/selectors.ts on lines 17..18

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 45.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

   private createParticipantInfo(participant: Participant): ParticipantStreams {
      const streams: ParticipantStreams = {
         consumers: {},
         producers: {},
      };
Severity: Minor
Found in src/Services/SFU/src/lib/conference/stream-info-repo.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 mapFormToDto has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const mapFormToDto: (form: CreatePollDto, myRoomId: string | undefined) => CreatePollDto = (form, myRoomId) => {
   const result = {
      ...form,
      instruction: Object.fromEntries(
         Object.entries(form.instruction).filter(

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 removeReceiveTransport has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

   public async removeReceiveTransport(connectionId: string): Promise<void> {
      const receiver = this.receivers.get(connectionId);
      if (receiver) {
         this.receivers.delete(connectionId);

Severity: Minor
Found in src/Services/SFU/src/lib/media-soup/mediasoup-mixer.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 getPollDescription has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const getPollDescription = (instruction: NumericInstruction, t: TFunction<string>) => {
   const modifiers = new Array<string>();

   if (typeof instruction.min === 'number' && typeof instruction.max === 'number') {
      modifiers.push(
Severity: Minor
Found in src/Web/WebSPA/Client/src/features/poll/types/numeric/index.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 onLiveUpdateReceived has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

   private onLiveUpdateReceived(update: WhiteboardLiveUpdateDto) {
      if (!this.currentCanvas) return;

      if (update.action.type === 'end') {
         this.removeLiveUpdate(update.participantId);
Severity: Minor
Found in src/Web/WebSPA/Client/src/features/whiteboard/whiteboard-controller.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 index has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function index({ conference }: Props) {
   const userInteractionMade = useSelector((state: RootState) => state.media.userInteractionMade);
   const playSoundOnConferenceOpen = useSelector((state: RootState) => state.settings.obj.conference.playSoundOnOpen);

   const myId = useMyParticipantId();
Severity: Minor
Found in src/Web/WebSPA/Client/src/features/conference/components/index.tsx - 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 removeConnection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

   public async removeConnection(connectionId: string): Promise<SuccessOrError> {
      const connection = this.connections.get(connectionId);
      if (!connection) return { success: false, error: errors.connectionNotFound(connectionId) };

      this.connections.delete(connection.connectionId);
Severity: Minor
Found in src/Services/SFU/src/lib/conference/conference.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 ErrorWrapper has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function ErrorWrapper({ failed, children, error, onRetry, type = 'alert' }: Props) {
   const classes = useStyles();
   const { t } = useTranslation();

   return failed ? (
Severity: Minor
Found in src/Web/WebSPA/Client/src/components/ErrorWrapper.tsx - 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 apply has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

   apply(fc: fabric.Canvas, action: ModifyingObjectsCanvasLiveAction, currentCanvas: WhiteboardCanvas): void {
      const objects = fc.getObjects();

      const previousEdited = [...this.modifiedObjs];
      this.modifiedObjs = [];
Severity: Minor
Found in src/Web/WebSPA/Client/src/features/whiteboard/live-update-handler.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 WebcamSettingsTest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function WebcamSettingsTest() {
   const classes = useStyles();
   const myId = useMyParticipantId();
   const { t } = useTranslation();
   const consumer = useConsumer(myId, 'loopback-webcam');

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 EquipmentRoute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function EquipmentRoute({
   location,
   match: {
      params: { id },
   },
Severity: Minor
Found in src/Web/WebSPA/Client/src/routes/EquipmentRoute.tsx - 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 clearChat has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      clearChat(state) {
         if (state.channels) {
            for (const channel of Object.values(state.channels)) {
               if (channel.viewModel) channel.viewModel.messages = [];
            }
Severity: Minor
Found in src/Web/WebSPA/Client/src/features/chat/reducer.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 unregisterConsumer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

   private unregisterConsumer(id: string): void {
      log('Unregister consumer %s', id);

      let currentUsage = this.consumerUsage.get(id);
      if (currentUsage === undefined) {
Severity: Minor
Found in src/Web/WebSPA/Client/src/store/webrtc/consumer-usage-control.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 onMouseDown has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

   onMouseDown(event: IEvent): void {
      if (event.target) return;

      const canvas = this.getCanvas();
      if (canvas.getActiveObject()) return;
Severity: Minor
Found in src/Web/WebSPA/Client/src/features/whiteboard/tools/TextTool.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