grigori-gru/matrix-cli

View on GitHub

Showing 43 of 43 total issues

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

        const iter = async (rooms = [], errors = []) => {
            if (!rooms.length) {
                return { errors, poweredRooms, errPoweredRooms };
            }

Severity: Minor
Found in src/lib/matrix-service.js - About 1 hr to fix

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

    const createMatrixClientStub = ignoreUsers => {
        const botId = fake.random.arrayElement(ignoreUsers);
    
        const matrixClientStub = { ...createStubInstance(MatrixClient) };
    
    
    Severity: Minor
    Found in __tests__/fixtures/fake-sdk.js - About 1 hr to fix

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

          getParsedRooms: (ignoreUsers = []) => room => {
              const roomId = room.roomId;
              const roomName = room.name;
              const [issueName] = room.name.split(' ');
              const project = issueName.includes('-') ? issueName.split('-')[0] : 'custom project';
      Severity: Minor
      Found in src/lib/utils.js - About 1 hr to fix

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

                if (isSave) {
                    const pathToFile = await this.matrixService.saveToJson(leavedRooms, 'leaved');
                    this.logger.log(chalk.blue('\nPath to file: '), chalk.yellow(pathToFile));
                }
        Severity: Major
        Found in src/lib/actions.js and 4 other locations - About 1 hr to fix
        src/lib/actions.js on lines 170..173
        src/lib/actions.js on lines 264..267
        src/lib/actions.js on lines 338..341
        src/lib/actions.js on lines 357..360

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

        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 5 locations. Consider refactoring.
        Open

                    if (isSave) {
                        const pathToFile = await this.matrixService.saveToJson(invitedRooms, 'invited');
                        this.logger.log(chalk.blue('\nPath to file: '), chalk.yellow(pathToFile));
                    }
        Severity: Major
        Found in src/lib/actions.js and 4 other locations - About 1 hr to fix
        src/lib/actions.js on lines 53..56
        src/lib/actions.js on lines 170..173
        src/lib/actions.js on lines 264..267
        src/lib/actions.js on lines 357..360

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

        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 5 locations. Consider refactoring.
        Open

                    if (isSave) {
                        const pathToFile = await this.matrixService.saveToJson(joinedRooms, 'joined');
                        this.logger.log(chalk.blue('\nPath to file: '), chalk.yellow(pathToFile));
                    }
        Severity: Major
        Found in src/lib/actions.js and 4 other locations - About 1 hr to fix
        src/lib/actions.js on lines 53..56
        src/lib/actions.js on lines 264..267
        src/lib/actions.js on lines 338..341
        src/lib/actions.js on lines 357..360

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

        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 5 locations. Consider refactoring.
        Open

                    if (isSave) {
                        const pathToFile = await this.matrixService.saveToJson(poweredRooms, 'powered');
                        this.logger.log(chalk.blue('\nPath to file: '), chalk.yellow(pathToFile));
                    }
        Severity: Major
        Found in src/lib/actions.js and 4 other locations - About 1 hr to fix
        src/lib/actions.js on lines 53..56
        src/lib/actions.js on lines 170..173
        src/lib/actions.js on lines 338..341
        src/lib/actions.js on lines 357..360

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

        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 5 locations. Consider refactoring.
        Open

                if (isSave) {
                    const pathToFile = await this.matrixService.saveToJson(info, 'info');
                    this.logger.log(chalk.blue('\nPath to file: '), chalk.yellow(pathToFile));
                }
        Severity: Major
        Found in src/lib/actions.js and 4 other locations - About 1 hr to fix
        src/lib/actions.js on lines 53..56
        src/lib/actions.js on lines 170..173
        src/lib/actions.js on lines 264..267
        src/lib/actions.js on lines 338..341

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

        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 iter has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                const iter = async (rooms = [], errors = []) => {
                    if (!rooms.length) {
                        return { errors, joinedRooms, errJoinedRooms };
                    }
        
        
        Severity: Minor
        Found in src/lib/matrix-service.js - About 1 hr to fix

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

              const singleRoomNoMessages = createSingleRooms(
                  correctLength,
                  [endDate.add(1, 'day').format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')],
                  `@${botId}:${fakeDomain}`,
              );
          Severity: Major
          Found in __tests__/fixtures/fake-sdk.js and 1 other location - About 1 hr to fix
          __tests__/fixtures/fake-sdk.js on lines 112..116

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

          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

              const manyMembersNoMessages = createRooms(
                  correctLength,
                  [endDate.add(1, 'day').format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')],
                  `@${botId}:${fakeDomain}`,
              );
          Severity: Major
          Found in __tests__/fixtures/fake-sdk.js and 1 other location - About 1 hr to fix
          __tests__/fixtures/fake-sdk.js on lines 117..121

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

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

              async send(room, optionalMessage) {
                  const { allRooms } = await this.matrixService.getAllRoomsInfo();
          
                  const rooms = room ? await this.matrixService.getRoomByName(room) : await this.ask.selectRooms(allRooms);
          
          
          Severity: Minor
          Found in src/lib/actions.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

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

                  const manyMembersNoMessages = parsedRooms.filter(room => {
                      return room.members.length > 1 && room.messages.length === 0;
                  });
          Severity: Minor
          Found in src/lib/matrix-service.js and 1 other location - About 50 mins to fix
          src/lib/matrix-service.js on lines 174..176

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

          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

                  const singleRoomsNoMessages = parsedRooms.filter(room => {
                      return room.members.length === 1 && room.messages.length === 0;
                  });
          Severity: Minor
          Found in src/lib/matrix-service.js and 1 other location - About 50 mins to fix
          src/lib/matrix-service.js on lines 182..184

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

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

              async setPower(rooms, matrixUserId, level) {
                  const poweredRooms = [];
                  const errPoweredRooms = [];
          
                  const iter = async (rooms = [], errors = []) => {
          Severity: Minor
          Found in src/lib/matrix-service.js - About 45 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 setPower has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              async setPower() {
                  const userId = await this._selectUser();
          
                  if (!userId) {
                      this.logger.log(chalk.yellow('\nNo user is selected\n'));
          Severity: Minor
          Found in src/lib/actions.js - About 45 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 inviteUserToRooms has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              async inviteUserToRooms(allRooms, userId) {
                  const client = this.client || (await this.getClient());
                  const invitedRooms = [];
                  const errInvitedRooms = [];
          
          
          Severity: Minor
          Found in src/lib/matrix-service.js - About 45 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 join has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              async join(allRooms) {
                  const client = this.client || (await this.getClient());
                  const joinedRooms = [];
                  const errJoinedRooms = [];
          
          
          Severity: Minor
          Found in src/lib/matrix-service.js - About 45 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

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

                  if (inviteRooms.length === 0) {
                      this.logger.log(chalk.yellow(`\nIn group ${strategy} no rooms found\n`));
                      return;
                  }
          Severity: Minor
          Found in src/lib/actions.js and 1 other location - About 40 mins to fix
          src/lib/actions.js on lines 246..249

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

          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

                  if (poweredRooms.length === 0) {
                      this.logger.log(chalk.yellow(`\nIn group ${strategy} no rooms found\n`));
                      return;
                  }
          Severity: Minor
          Found in src/lib/actions.js and 1 other location - About 40 mins to fix
          src/lib/actions.js on lines 319..322

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

          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