Showing 254 of 254 total issues

Function introduceUsers has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

async function introduceUsers(user, userGIds, session, socket) {
  if (session) {
    // If no session is given, force broadcast userGids without remembering them
    session.knownUserGIds = session.knownUserGIds || {};
  }
Severity: Minor
Found in server/lib/userIntroducer.js - 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

File component.js has 390 lines of code (exceeds 250 allowed). Consider refactoring.
Open

//
//   Copyright 2009-2014 Ilkka Oksanen <iao@iki.fi>
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
Severity: Minor
Found in client/app/pods/components/window-grid/component.js - About 5 hrs to fix

    Function WindowSettings has 129 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const WindowSettings: FunctionComponent = () => {
      const { windowStore } = useContext(ServerContext);
      const window = windowStore.activeWindow;
      const [topic, setTopic] = useState<string | null>(null);
      const [requestedNotificationPermission, setRequestedNotificationPermission] = useState<boolean>(false);
    Severity: Major
    Found in new-client/src/components/WindowSettings.tsx - About 5 hrs to fix

      Function _dragWindowEnd has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

        _dragWindowEnd(event) {
          const cursor = this.cursor;
      
          this.set('draggedWindow', false);
          this.movingWindow.$().removeClass('moving').css('z-index', '');
      Severity: Minor
      Found in client/app/pods/components/window-grid/component.js - About 4 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

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

              resp.msgs.forEach(({ gid, userId, ts, cat, body, updatedTs, status }) => {
                window.logMessages.set(gid, new Message(this, { gid, userId, ts, cat, body, updatedTs, status, window }));
              });
      Severity: Major
      Found in client/app/stores/WindowStore.js and 1 other location - About 4 hrs to fix
      client/app/stores/WindowStore.js on lines 355..357

      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 119.

      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

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

              resp.msgs.forEach(({ gid, userId, ts, cat, body, updatedTs, status }) => {
                window.messages.set(gid, new Message(this, { gid, userId, ts, cat, body, updatedTs, status, window }));
              });
      Severity: Major
      Found in client/app/stores/WindowStore.js and 1 other location - About 4 hrs to fix
      client/app/stores/WindowStore.js on lines 330..332

      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 119.

      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

      WindowStore has 33 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class WindowStore {
        @observable windows = new Map();
        msgBuffer = []; // Only used during startup
        cachedUpto = 0;
        @observable initDone = false;
      Severity: Minor
      Found in client/app/stores/WindowStore.js - About 4 hrs to fix

        Function MessageRow has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        const MessageRow: FunctionComponent<MessageRowProps> = ({ message, isUnread }: MessageRowProps) => {
          const modal = useContext(ModalContext);
          const { windowStore, userStore } = useContext(ServerContext);
          const [isFocused, setFocused] = useState<boolean>(false);
          const [editedBody, setEditedBody] = useState<string | null>(null);
        Severity: Minor
        Found in new-client/src/components/MessageRenderer.tsx - About 3 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 Profile has 97 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const Profile: FunctionComponent = () => {
          const toast = useToast();
          const { profileStore, userStore } = useContext(ServerContext);
          const [name, setName] = useState<string>('');
          const [email, setEmail] = useState<string>('');
        Severity: Major
        Found in new-client/src/components/Profile.tsx - About 3 hrs to fix

          Function scanMentions has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

          exports.scanMentions = async function scanMentions(conversation, message) {
            if (!message.get('userGId') || message.get('userGId') === 'i0' || !message.get('body')) {
              return;
            }
          
          
          Severity: Minor
          Found in server/services/windows.js - About 3 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 _parseLinks has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

            _parseLinks(text) {
              const imgSuffixes = ['png', 'jpg', 'jpeg', 'gif', 'webp'];
              const media = [];
              let body = '';
          
          
          Severity: Minor
          Found in client/app/models/Message.js - About 3 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

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

          async function handleTopic(user, msg) {
            // :ilkka!ilkkao@localhost.myrootshell.com TOPIC #portaali :My new topic
            const channel = msg.params[0];
            const topic = msg.params[1];
            const conversation = await Conversation.findFirst({
          Severity: Major
          Found in server/backends/irc/controller.js and 1 other location - About 3 hrs to fix
          server/backends/irc/controller.js on lines 601..614

          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 105.

          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

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

          async function handle332(user, msg) {
            // :portaali.org 332 ilkka #portaali :Cool topic
            const channel = msg.params[0];
            const topic = msg.params[1];
            const conversation = await Conversation.findFirst({
          Severity: Major
          Found in server/backends/irc/controller.js and 1 other location - About 3 hrs to fix
          server/backends/irc/controller.js on lines 1031..1044

          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 105.

          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

          MessageModel has 28 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export default class MessageModel {
            public readonly gid: number;
            public body = '';
            public doc?: RemirrorJSON;
            private readonly category: MessageCategory;
          Severity: Minor
          Found in new-client/src/models/Message.ts - About 3 hrs to fix

            MessageModel has 28 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export default class MessageModel {
              gid = 0;
              @observable body = null;
              cat = null;
              ts = null;
            Severity: Minor
            Found in client/app/models/Message.js - About 3 hrs to fix

              File conversations.js has 302 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              //
              //   Copyright 2014 Ilkka Oksanen <iao@iki.fi>
              //
              //   Licensed under the Apache License, Version 2.0 (the "License");
              //   you may not use this file except in compliance with the License.
              Severity: Minor
              Found in server/services/conversations.js - About 3 hrs to fix

                `` has 27 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export default Component.extend({
                  init(args) {
                    this._super(args);
                
                    this.content = EmberObject.create();
                Severity: Minor
                Found in client/app/pods/components/discussion-window/component.js - About 3 hrs to fix

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

                            <FormControl display="flex" alignItems="center">
                              <Switch
                                isChecked={alerts.email}
                                onChange={e => handleChangeAlert('email', e.target.checked)}
                                mx="1rem"
                  Severity: Major
                  Found in new-client/src/components/WindowSettings.tsx and 3 other locations - About 3 hrs to fix
                  new-client/src/components/WindowSettings.tsx on lines 100..110
                  new-client/src/components/WindowSettings.tsx on lines 111..121
                  new-client/src/components/WindowSettings.tsx on lines 122..132

                  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 98.

                  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

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

                            <FormControl display="flex" alignItems="center">
                              <Switch
                                isChecked={alerts.title}
                                onChange={e => handleChangeAlert('title', e.target.checked)}
                                mx="1rem"
                  Severity: Major
                  Found in new-client/src/components/WindowSettings.tsx and 3 other locations - About 3 hrs to fix
                  new-client/src/components/WindowSettings.tsx on lines 100..110
                  new-client/src/components/WindowSettings.tsx on lines 122..132
                  new-client/src/components/WindowSettings.tsx on lines 133..143

                  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 98.

                  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

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

                            <FormControl display="flex" alignItems="center">
                              <Switch
                                isChecked={alerts.notification}
                                onChange={e => handleChangeAlert('notification', e.target.checked)}
                                mx="1rem"
                  Severity: Major
                  Found in new-client/src/components/WindowSettings.tsx and 3 other locations - About 3 hrs to fix
                  new-client/src/components/WindowSettings.tsx on lines 100..110
                  new-client/src/components/WindowSettings.tsx on lines 111..121
                  new-client/src/components/WindowSettings.tsx on lines 133..143

                  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 98.

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language