CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-snazzy

Format JavaScript Standard Style as Stylish (i.e. snazzy) output

94

1.18x
Overview
Eval results
Files

task.mdevals/scenario-6/

Code Analysis Reporter

Build a command-line tool that analyzes code quality reports and exits with appropriate status codes for CI/CD pipeline integration.

Requirements

Your tool should read JSON-formatted code quality reports from stdin and output a summary to stdout. The tool must set appropriate exit codes based on the analysis results to enable proper CI/CD integration.

Input Format

The tool receives JSON data via stdin with the following structure:

{
  "files": [
    {
      "path": "src/app.js",
      "issues": [
        {"severity": "error", "message": "Undefined variable"},
        {"severity": "warning", "message": "Unused import"}
      ]
    }
  ]
}

Output Requirements

  1. Display a summary showing:

    • Total number of files analyzed
    • Total number of issues found
    • Breakdown by severity (errors and warnings)
  2. Exit code behavior:

    • Exit with code 0 if no errors are found (warnings are acceptable)
    • Exit with code 1 if one or more errors are found
    • The exit code must be set reliably, even when dealing with asynchronous operations

Implementation Notes

  • The tool should handle stdin input properly
  • Output formatting is flexible (plain text is sufficient)
  • The exit code must be set after all asynchronous processing completes
  • The tool should work correctly when piped from other commands

Test Cases

  • Reading a report with no issues exits with code 0 @test
  • Reading a report with only warnings exits with code 0 @test
  • Reading a report with errors exits with code 1 @test
  • Reading a report with both errors and warnings exits with code 1 @test

Implementation

@generates

API

/**
 * Analyzes code quality reports and sets appropriate exit codes.
 * Extends Transform stream to process JSON input from stdin.
 */
class CodeAnalyzer extends require('stream').Transform {
  constructor(options);

  /**
   * Exit code to be set based on analysis results.
   * 0 = no errors found, 1 = errors detected
   */
  exitCode: number;
}

module.exports = CodeAnalyzer;

Dependencies { .dependencies }

readable-stream { .dependency }

Provides Node.js stream support for processing stdin data.

Install with Tessl CLI

npx tessl i tessl/npm-snazzy

tile.json