Showing 165 of 254 total issues

File controller.js has 1001 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env node
//
//   Copyright 2009-2014 Ilkka Oksanen <iao@iki.fi>
//
//   Licensed under the Apache License, Version 2.0 (the "License");
Severity: Major
Found in server/backends/irc/controller.js - About 2 days to fix

    File WindowStore.ts has 664 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { autorun, observable, computed, makeObservable, action, runInAction } from 'mobx';
    import dayjs from 'dayjs';
    import { RemirrorJSON } from 'remirror';
    import Message from '../models/Message';
    import Window, { WindowMoveDirection } from '../models/Window';
    Severity: Major
    Found in new-client/src/stores/WindowStore.ts - About 1 day to fix

      File WindowStore.js has 623 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { observable, computed } from 'mobx';
      import moment from 'moment';
      import Cookies from 'js-cookie';
      import isMobile from 'ismobilejs';
      import { dispatch } from '../utils/dispatcher';
      Severity: Major
      Found in client/app/stores/WindowStore.js - About 1 day to fix

        Function main has 255 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        (async function main() {
          const { val, reason } = await db.setSchema({
            users: {
              definition: {
                deleted: { type: 'boolean', allowNull: false },
        Severity: Major
        Found in server/bin/create-db.ts - About 1 day to fix

          File component.js has 480 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/discussion-window/component.js - About 7 hrs to fix

            File request.js has 450 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/controllers/request.js - About 6 hrs to fix

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

              class WindowStore {
                rootStore: RootStore;
                socket: Socket;
                windows = new Map<number, Window>();
                activeWindow: Window | null = null;
              Severity: Minor
              Found in new-client/src/stores/WindowStore.ts - About 6 hrs to fix

                Function handleMode has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
                Open

                async function handleMode(user, msg) {
                  // :ilkka9!~ilkka9@localhost.myrootshell.com MODE #sunnuntai +k foobar3
                  const target = msg.params[0];
                
                  if (!isChannel(target)) {
                Severity: Minor
                Found in server/backends/irc/controller.js - About 6 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 setup has 152 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports.setup = function setup(server) {
                  const io = socketIo(server, {
                    maxHttpBufferSize: 1e8,
                    pingInterval: 10000,
                    pingTimeout: 15000,
                Severity: Major
                Found in server/controllers/socket.js - About 6 hrs to fix

                  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

                      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

                          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
                              Severity
                              Category
                              Status
                              Source
                              Language