Showing 17 of 27 total issues
Function startWorkers
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = async function startWorkers(config, dir, pack, workerCount, args = [], env = {}, connection) {
const workers = []
if (pack.name === 'z1') {
throw new Error('the name "z1" is invalid')
Remote
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class Remote extends BetterEvents {
/**
* Create a new Remote instance.
* @param {string} socketFile - Path to the socket file of the z1 daemon.
*/
Function constructor
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(dir, file, name, ports, env) {
super()
this.dir = dir
this.file = file
Function remoteServer
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function remoteServer(filename, run) {
const file = path.resolve(filename)
const server = net.createServer(OPT, socket => {
socket.on('error', handle)
Function setup
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
setup(id, dir = '') {
const streams = this.get(id)
// End old streams and cancel old log rotation.
clearTimeout(streams.timeout)
Function list
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function list(config) {
return new Promise(resolve => {
const stats = {}
/**
Function sendLogsToCLI
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function sendLogsToCLI(target, connection) {
const convert = chunk => Array.from(Buffer.from(chunk))
const emit = (ev, chunk) => connection.remoteEmit(ev, convert(chunk))
const sendOutToCLI = chunk => emit('stdout', chunk)
const sendErrToCLI = chunk => emit('stderr', chunk)
Function _send
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
async _send(object) {
return new Promise((resolve, reject) => {
const socket = net.connect(this.socketFile, () => {
const connection = new Connection(socket)
Function sendLogsToCLI
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function sendLogsToCLI(target, connection) {
const convert = chunk => Array.from(Buffer.from(chunk))
const emit = (ev, chunk) => connection.remoteEmit(ev, convert(chunk))
const sendOutToCLI = chunk => emit('stdout', chunk)
const sendErrToCLI = chunk => emit('stderr', chunk)
- 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 restart
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function restart(config, command, connection) {
// find old app
const app = config.apps.find(app => app.name === command.app)
if (!app) {
Function start
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function start(config, command, connection) {
if (global.isResurrectable) {
global.isResurrectable = false
config.apps = []
}
Function constructor
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
constructor(dir, file, name, ports, env) {
super()
this.dir = dir
this.file = file
- 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 exports
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
module.exports = async function startWorkers(config, dir, pack, workerCount, args = [], env = {}, connection) {
Function startWorkers
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
module.exports = async function startWorkers(config, dir, pack, workerCount, args = [], env = {}, connection) {
const workers = []
if (pack.name === 'z1') {
throw new Error('the name "z1" is invalid')
- 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 verifyPorts
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function verifyPorts(pack, prop, origin = 'package.json') {
const ports = pack[prop]
if (Array.isArray(ports)) {
if (ports.length) {
- 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 _waitForDisconnect
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
async _waitForDisconnect() {
while (1) {
try {
await this._ping()
await xTime(100)
- 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 _waitForConnection
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
async _waitForConnection() {
while (1) {
try {
await this._ping()
return
- 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"