
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Analyzes TypeScript files for Cyclomatic Complexity, Halstead Volume, LOC and Maintainability Index
Marvins Code Quality Analyzer is a command-line tool designed to analyze TypeScript source files and provide valuable insights into your code's quality. By calculating several key metrics, Marvins helps developers identify potential issues, understand code complexity, and ensure maintainability.
The tool leverages the TypeScript compiler API to generate an Abstract Syntax Tree (AST), which is then traversed to compute various code quality metrics. These metrics include:
An Abstract Syntax Tree (AST) is a tree representation of the abstract syntactic structure of source code. Each node in the tree denotes a construct in the source code. In Marvins, the TypeScript compiler API is used to generate an AST from a source file. This AST is then traversed to:
Using the AST allows Marvins to perform a detailed and accurate analysis of code structure and quality.
Marvins is operated entirely via the command line. The CLI supports several commands to configure thresholds, update multipliers, and perform analysis on TypeScript files.
Marvins uses a config.json file located in the current working directory to store default thresholds and multipliers. If this file does not exist, it is automatically created with the following default values:
{
"cyclomatic": { "medium": 6, "high": 10 },
"maintainabilityIndex": { "low": 40, "medium": 60 },
"loc": { "medium": 30, "high": 50 },
"commentDensityMultiplier": 5
}
marvins help
Marvins provides two configuration options:
marvins configure -t <metric> <value1> <value2>
Parameters:
<metric>: The metric to update. Valid options are:
cyclomaticmaintainabilityIndexloc<value1>: The first threshold value (e.g., "medium" for cyclomatic or LOC, "low" for maintainabilityIndex).<value2>: The second threshold value (e.g., "high" for cyclomatic or LOC, "medium" for maintainabilityIndex).Example:
marvins configure -t cyclomatic 6 10
This updates the cyclomatic complexity thresholds to a medium value of 6 and a high value of 10.
marvins configure -d <value>
Parameters:
<value>: A numeric value that updates the comment density multiplier used in the MI calculation.Example:
marvins configure -d 7
This updates the comment density multiplier to 7.
marvins analyze -f {typescript filePath}
Parameters:
{typescript filePath}: Path to the TypeScript file you wish to analyze.Description:
Analyzes the specified TypeScript file and displays the computed metrics, including:
Example:
marvins analyze -f src/app.ts
This command analyzes the src/app.ts file and outputs the analysis results.
Marvins Code Quality Analyzer is a powerful tool that leverages static analysis and AST traversal to provide insights into code quality. By monitoring metrics such as Cyclomatic Complexity, Halstead Volume, Lines of Code, Maintainability Index, and Comment Density, developers can better understand and improve their codebase.
For further information or assistance, simply run:
marvins help
Enjoy using Marvins to keep your code clean, maintainable, and of high quality!
FAQs
Analyzes TypeScript files for Cyclomatic Complexity, Halstead Volume, LOC and Maintainability Index
We found that marvins demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.