Showing 165 of 254 total issues

Consider simplifying this complex logical expression.
Open

    if (
      (y === 0 && cursor === 'top') ||
      (y === rows - 1 && cursor === 'bottom') ||
      (x === 0 && cursor === 'left') ||
      (x === columns - 1 && cursor === 'right')
Severity: Critical
Found in client/app/pods/components/window-grid/component.js - About 1 hr to fix

    Function findOrCreate1on1 has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.findOrCreate1on1 = async function findOrCreate1on1(user, peerUserGId, network) {
      assert(user && peerUserGId && network);
    
      let conversation = null;
      const userMembers = await ConversationMember.find({ userGId: user.gIdString });
    Severity: Minor
    Found in server/services/conversations.js - About 1 hr to fix

      Function createFrontendApp has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function createFrontendApp() {
        const app = new Koa();
      
        app.on('error', err => {
          if (err.status !== 404 && !error.errno === 'EPIPE') {
      Severity: Minor
      Found in server/server.js - About 1 hr to fix

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

        function main() {
          const { mode, fileName: mainEntryFileName } = getMainEntryFileNameAndMode();
          const googleAuthEnabled = process.env['GOOGLE_AUTH'] === 'true';
          const serverPort = process.env['WEB_SERVER_PORT'] || 3100;
        
        
        Severity: Minor
        Found in website/server.ts - About 1 hr to fix

          Function handleIdentConnection has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function handleIdentConnection(socket) {
            const timer = setTimeout(() => {
              if (socket) {
                socket.destroy();
              }
          Severity: Minor
          Found in server/backends/irc/connection-manager/connectionManager.js - About 1 hr to fix

            Function createReset has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            exports.createReset = async function createReset(ctx) {
              const form = await decodeForm(ctx.req, registrationFormReset);
              const userId = await redis.get(`frontend:password_reset_token:${form.data.token}`);
            
              async function renderForm() {
            Severity: Minor
            Found in server/controllers/register.js - About 1 hr to fix

              Function create has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                static async create(props, { skipSetters = false } = {}) {
                  trimWhiteSpace(props);
              
                  if (!skipSetters) {
                    const passwordValidation = validatePassword(props.password);
              Severity: Minor
              Found in server/models/user.js - About 1 hr to fix

                Function createNodeSpec has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  createNodeSpec(extra: ApplySchemaAttributes, override: NodeSpecOverride): NodeExtensionSpec {
                    return {
                      selectable: true,
                      draggable: false,
                      ...override,
                Severity: Minor
                Found in new-client/src/lib/remirrorMessageEmojiExtension.ts - About 1 hr to fix

                  Function handleUpdateWindowServer has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    handleUpdateWindowServer({
                      windowId = mandatory(),
                      userId,
                      network,
                      windowType,
                  Severity: Minor
                  Found in client/app/stores/WindowStore.js - About 1 hr 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 handleCommand has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  async function handleCommand({ command, conversation, user, backend }) {
                    const { command: name, params } = command;
                  
                    if (!conversation) {
                      return { status: 'ERROR', errorMsg: 'Invalid windowId.' };
                  Severity: Minor
                  Found in server/controllers/request.js - About 1 hr 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 handleProcessLine has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    handleProcessLine({ window = mandatory(), body = mandatory() }) {
                      let command = false;
                      let commandParams;
                  
                      if (body.charAt(0) === '/') {
                  Severity: Minor
                  Found in client/app/stores/WindowStore.js - About 1 hr to fix

                    Function sendText has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      async sendText(window: WindowModel, text: string, doc?: RemirrorJSON): Promise<void> {
                        let sent = false;
                    
                        setTimeout(() => {
                          if (!sent) {
                    Severity: Minor
                    Found in new-client/src/stores/WindowStore.ts - About 1 hr to fix

                      Function getMessageRange has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export async function getMessageRange(conversationId, start, end, amount) {
                        if (!elasticSearchAvailable()) {
                          return [];
                        }
                      
                      
                      Severity: Minor
                      Found in server/lib/search.ts - About 1 hr to fix

                        Function dispatch has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function dispatch(type, data = {}, acceptCb = noopCb, rejectCb = noopCb) {
                          let consumed = false;
                          const name = type
                            .split('_')
                            .map(part => part.toLowerCase().capitalize())
                        Severity: Minor
                        Found in client/app/utils/dispatcher.js - About 1 hr to fix

                          Function _whichSection has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            _whichSection(windowDim, x, y) {
                              // -----------------
                              // |\      t      /|
                              // | \           / |
                              // |  -----------  |
                          Severity: Minor
                          Found in client/app/pods/components/window-grid/component.js - About 1 hr to fix

                            Function process has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            exports.process = async function process(session, command) {
                              const { windowId } = command;
                              const network = typeof command.network === 'string' ? command.network.toLowerCase() : null;
                              const user = session.user;
                            
                            
                            Severity: Minor
                            Found in server/controllers/request.js - About 1 hr to fix

                              Function useMessageRemirror has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export function useMessageRemirror(): MessageRemirror {
                                const extensions = useMemo(
                                  () => () =>
                                    [
                                      new BoldExtension(),
                              Severity: Minor
                              Found in new-client/src/hooks/remirror.ts - About 1 hr to fix

                                Function deleteConversationMember has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                async function deleteConversationMember(conversation, member, options) {
                                  log.info(`User: ${member.get('userGId')} removed from conversation: ${conversation.id}`);
                                
                                  if (!options.silent && conversation.get('type') === 'group') {
                                    await broadcastAddMessage(conversation, {
                                Severity: Minor
                                Found in server/services/conversations.js - About 1 hr to fix

                                  Function updateMembers has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    updateMembers(id: number, members: Array<{ userId: string; role: Role }>, reset: boolean): void {
                                      const window = this.windows.get(id);
                                  
                                      if (!window) {
                                        return;
                                  Severity: Minor
                                  Found in new-client/src/stores/WindowStore.ts - About 1 hr to fix

                                    Function _calculateCursorPosition has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      _calculateCursorPosition(event) {
                                        const outOfBoundsCursor = { x: null, y: null, section: null };
                                    
                                        const x = event.clientX;
                                        const y = event.clientY;
                                    Severity: Minor
                                    Found in client/app/pods/components/window-grid/component.js - About 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language