Showing 165 of 254 total issues

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

      Function init has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exports.init = async function init(user, session, maxBacklogLines, cachedUpto) {
        await settingsService.sendUpdateSettings(user, session.id);
        await friendsService.sendUpdateFriends(user, session.id);
        await friendsService.sendConfirmFriends(user, session.id);
        await friendsService.informStateChange(user, 'login');
      Severity: Major
      Found in server/services/session.js - About 2 hrs to fix

        Function handleMode has 66 lines of code (exceeds 25 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: Major
        Found in server/backends/irc/controller.js - About 2 hrs to fix

          Function didInsertElement has 65 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            didInsertElement() {
              this.sendAction('register', this);
              this.set('elementInserted', true);
          
              this.$messagePanel = this.$('.window-messages');
          Severity: Major
          Found in client/app/pods/components/discussion-window/component.js - About 2 hrs to fix

            Function RegisterModal has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

            export const RegisterModal: FunctionComponent<RegisterModalProps> = ({ isOpen, onClose }: RegisterModalProps) => {
              const validateName = (value: string) => {
                if (!value) {
                  return 'Name is required';
                } else if (value.length < 6) {
            Severity: Minor
            Found in website/src/components/RegisterModal.tsx - About 2 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 configTransports has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

            function configTransports() {
              const transports = [];
            
              if (get('log:file')) {
                let logDirectory = path.normalize(get('log:directory'));
            Severity: Minor
            Found in server/lib/log.ts - About 2 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 create-db.ts has 273 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            //
            //   Copyright 2015 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/bin/create-db.ts - About 2 hrs to fix

              File MessageRenderer.tsx has 271 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import React, { FunctionComponent, useContext, useState, KeyboardEvent } from 'react';
              import {
                Button,
                Box,
                Flex,
              Severity: Minor
              Found in new-client/src/components/MessageRenderer.tsx - About 2 hrs to fix

                Function WindowSettings has a Cognitive Complexity of 17 (exceeds 5 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: Minor
                Found in new-client/src/components/WindowSettings.tsx - About 2 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 updateNick has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                async function updateNick(user, network, oldNick, newNick) {
                  let changed = false;
                  let targetUserGId = null;
                  const nickUser = await nicksService.getUser(oldNick, network);
                
                
                Severity: Major
                Found in server/backends/irc/controller.js - About 2 hrs to fix

                  File Message.js has 257 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import { computed, observable } from 'mobx';
                  import marked from 'marked';
                  import emojione from 'emojione';
                  import moment from 'moment';
                  import URI from 'urijs';
                  Severity: Minor
                  Found in client/app/models/Message.js - About 2 hrs to fix

                    Function _dragWindowEnd has 54 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      _dragWindowEnd(event) {
                        const cursor = this.cursor;
                    
                        this.set('draggedWindow', false);
                        this.movingWindow.$().removeClass('moving').css('z-index', '');
                    Severity: Major
                    Found in client/app/pods/components/window-grid/component.js - About 2 hrs to fix

                      Function constructor has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        constructor() {
                          if (!this.cookie) {
                            console.error(`Session cookie not found or corrupted. Exiting.`);
                            this._logout();
                          }
                      Severity: Major
                      Found in client/app/utils/socket.js - About 2 hrs to fix

                        Function Sidebar has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                        const Sidebar: FunctionComponent<SidebarProps> = ({ fullScreen = false, showDesktops }: SidebarProps) => {
                          const { windowStore } = useContext(ServerContext);
                        
                          const sortWindows = (windows: WindowModel[]) => {
                            return windows.sort((a, b) => {
                        Severity: Minor
                        Found in new-client/src/components/Sidebar.tsx - About 2 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 LoginModal has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export const LoginModal: FunctionComponent<LoginModalProps> = ({ isOpen, onClose }: LoginModalProps) => {
                          const [mode, setMode] = useState<Mode>(Mode.Login);
                        
                          const googleRedirect = () => {
                            window.location.pathname = '/auth/google';
                        Severity: Minor
                        Found in website/src/components/LoginModal.tsx - About 2 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 updateNick has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                        Open

                        async function updateNick(user, network, oldNick, newNick) {
                          let changed = false;
                          let targetUserGId = null;
                          const nickUser = await nicksService.getUser(oldNick, network);
                        
                        
                        Severity: Minor
                        Found in server/backends/irc/controller.js - About 2 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 requests.ts has 252 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import { Network, MessageRecord, AlertsRecord } from './notifications';
                        
                        export interface CreateRequest {
                          id: 'CREATE';
                          name: string;
                        Severity: Minor
                        Found in new-client/src/types/requests.ts - About 2 hrs to fix

                          Function setup has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function setup() {
                            if (conf.get('googleauth:enabled')) {
                              const GoogleStrategy = require('passport-google-oauth').OAuth2Strategy;
                              const jwt = require('jwt-simple');
                          
                          
                          Severity: Major
                          Found in server/lib/passport.js - About 2 hrs to fix

                            Function introduceUsers has 51 lines of code (exceeds 25 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: Major
                            Found in server/lib/userIntroducer.js - About 2 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language