zenflow/composite-service

View on GitHub

Showing 8 of 8 total issues

Function validateDependencyTree has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
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)) {
Severity: Minor
Found in src/validateAndNormalizeConfig.ts - About 1 hr to fix

Function validateDependencyTree has 33 lines of code (exceeds 25 allowed). Consider refactoring.
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)) {
Severity: Minor
Found in src/validateAndNormalizeConfig.ts - About 1 hr to fix

    Function constructor has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    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
    Severity: Minor
    Found in src/CompositeService.ts - About 1 hr to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      if (this.config.crashesLength > 0) {
      this.crashes.push(crash);
      if (this.crashes.length > this.config.crashesLength) {
      this.crashes.shift();
      }
      Severity: Major
      Found in src/Service.ts and 1 other location - About 1 hr to fix
      src/ServiceProcess.ts on lines 41..46

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      tapStreamLines((line) => {
      this.logTail.push(line);
      if (this.logTail.length > this.serviceConfig.logTailLength) {
      this.logTail.shift();
      }
      Severity: Major
      Found in src/ServiceProcess.ts and 1 other location - About 1 hr to fix
      src/Service.ts on lines 91..96

      Function handleCrash has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      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(),
      Severity: Minor
      Found in src/Service.ts - About 1 hr to fix

        Function constructor has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        constructor(
        serviceId: string,
        serviceConfig: NormalizedServiceConfig,
        logger: Logger,
        onCrash: () => void
        Severity: Minor
        Found in src/ServiceProcess.ts - About 1 hr to fix

          Function end has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          public end(windowsCtrlCShutdown: boolean) {
          if (!this.wasEndCalled) {
          this.wasEndCalled = true;
          if (this.isRunning()) {
          if (windowsCtrlCShutdown) {
          Severity: Minor
          Found in src/ServiceProcess.ts - About 45 mins to fix
          Severity
          Category
          Status
          Source
          Language