grigori-gru/matrix-cli

View on GitHub

Showing 24 of 43 total issues

File matrix-service.js has 389 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const fileSystem = require('fs').promises;
const matrixSdk = require('matrix-js-sdk');
const url = require('url');
const { getParsedRooms, isEnglish, timing, getOutdatedRooms } = require('./utils');
const Listr = require('listr');
Severity: Minor
Found in src/lib/matrix-service.js - About 5 hrs to fix

    File actions.js has 285 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const { formatName } = require('./utils');
    const chalk = require('chalk');
    const myLogger = require('./logger');
    // eslint-disable-next-line
    const MatrixService = require('./matrix-service');
    Severity: Minor
    Found in src/lib/actions.js - About 2 hrs to fix

      exports has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      module.exports = class {
          /**
           * @param {object} sdk sdk client
           */
          constructor({
      Severity: Minor
      Found in src/lib/matrix-service.js - About 2 hrs to fix

        Function leaveRooms has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            async leaveRooms(allRooms, options = {}) {
                const client = this.client || (await this.getClient());
                const leavedRooms = [];
                const errLeavedRooms = [];
        
        
        Severity: Minor
        Found in src/lib/matrix-service.js - About 1 hr to fix

          Function inviteUserToRooms has 43 lines of code (exceeds 25 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 1 hr to fix

            Function selectRooms has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const selectRooms = async rooms => {
                const preparedRooms = rooms.map(({ roomName }) => ({ name: roomName, message: roomName }));
                const prompt = new MultiSelect({
                    name: 'rooms',
                    message: chalk.blueBright('Select rooms'),
            Severity: Minor
            Found in src/lib/questions.js - About 1 hr to fix

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

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

                Function leaveRooms has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                    async leaveRooms(allRooms, options = {}) {
                        const client = this.client || (await this.getClient());
                        const leavedRooms = [];
                        const errLeavedRooms = [];
                
                
                Severity: Minor
                Found in src/lib/matrix-service.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 selectRooms has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                const selectRooms = async rooms => {
                    const preparedRooms = rooms.map(({ roomName }) => ({ name: roomName, message: roomName }));
                    const prompt = new MultiSelect({
                        name: 'rooms',
                        message: chalk.blueBright('Select rooms'),
                Severity: Minor
                Found in src/lib/questions.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 setPower has 38 lines of code (exceeds 25 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 1 hr to fix

                  Function join has 38 lines of code (exceeds 25 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 1 hr to fix

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

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

                      Function setPower has 35 lines of code (exceeds 25 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 1 hr to fix

                        Function getClient has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            async getClient() {
                                const tasks = new Listr([
                                    {
                                        title: spinLoginText,
                                        task: async ctx => {
                        Severity: Minor
                        Found in src/lib/matrix-service.js - About 1 hr to fix

                          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

                                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

                                  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

                                  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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language