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');
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');
exports
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
module.exports = class {
/**
* @param {object} sdk sdk client
*/
constructor({
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 = [];
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 = [];
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'),
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 };
}
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 = [];
- Read upRead up
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'),
- Read upRead up
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 = []) => {
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 = [];
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 };
}
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'));
Function getClient
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getClient() {
const tasks = new Listr([
{
title: spinLoginText,
task: async ctx => {
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 };
}
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) };
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';
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 };
}
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);
- Read upRead up
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 = []) => {
- Read upRead up
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"