Showing 6 of 8 total issues
Function validateDependencyTree
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
Open
function validateDependencyTree(services: { [id: string]: NormalizedServiceConfig }): void {
const serviceIds = Object.keys(services);
for (const [serviceId, { dependencies }] of Object.entries(services)) {
for (const dependency of dependencies) {
if (!serviceIds.includes(dependency)) {
- 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 validateDependencyTree
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function validateDependencyTree(services: { [id: string]: NormalizedServiceConfig }): void {
const serviceIds = Object.keys(services);
for (const [serviceId, { dependencies }] of Object.entries(services)) {
for (const dependency of dependencies) {
if (!serviceIds.includes(dependency)) {
Function constructor
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
constructor(config: NormalizedCompositeServiceConfig) {
this.config = config;
if (this.config.windowsCtrlCShutdown) {
require("generate-ctrl-c-event"); // make sure this module loads before we even start
Function handleCrash
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private async handleCrash(proc: ServiceProcess) {
this.logger.log("info", `Service '${this.id}' crashed`);
const delayPromise = delay(this.config.minimumRestartDelay);
const crash: ServiceCrash = {
date: new Date(),
Function constructor
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
constructor(
serviceId: string,
serviceConfig: NormalizedServiceConfig,
logger: Logger,
onCrash: () => void
Function end
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
public end(windowsCtrlCShutdown: boolean) {
if (!this.wasEndCalled) {
this.wasEndCalled = true;
if (this.isRunning()) {
if (windowsCtrlCShutdown) {
- 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"