Showing 5 of 7 total issues
Function runCommand
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function runCommand(command: string, args: string[], additionalEnv?: NodeJS.ProcessEnv, silent: boolean = false): Promise<CommandResult> {
return new Promise<CommandResult>((resolve, reject) => {
try {
debug(`Additional environment variables: ${JSON.stringify(additionalEnv)}`);
debug(`Command: ${command} ${args.join(' ')}`);
Function main
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async function main(argv: string[]): Promise<number> {
// Disable colors if $PKO_NO_COLOR is set to a truthy value
if (process.env.PKO_NO_COLOR) {
colors.disable();
}
Function startVerdaccio
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function startVerdaccio(storage: string, forPublishing: boolean): Promise<VerdaccioHandle> {
const packages = forPublishing ? { '**': { access: '$all', publish: '$all' } } : await buildPackageConfig(storage);
return await new Promise<VerdaccioHandle>((resolve, reject) => {
function verdaccioHandler(webServer: http.Server, addr: any, _pkgName: string, _pkgVersion: string) {
webServer.listen(addr.port || addr.path, addr.host, () => {
Function main
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
async function main(argv: string[]): Promise<number> {
// Disable colors if $PKO_NO_COLOR is set to a truthy value
if (process.env.PKO_NO_COLOR) {
colors.disable();
}
- 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 findAllPackages
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
export async function findAllPackages(dir: string): Promise<PackageVersion[]> {
const packages = new Array<PackageVersion>();
for (const file of await fs.readdir(dir)) {
const fullPath = path.join(dir, file);
if (file === 'package.json') {
- 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"