Codibre/anypm

View on GitHub

Showing 3 of 5 total issues

Function getTypes has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export async function getTypes(packages: string[], current?: Set<string>) {
    function* getPackages() {
        for (const pkg of packages) {
            if (!pkg.startsWith('@types')) {
                const typePackage = `@types/${
Severity: Minor
Found in src/lib/get-types.ts - About 1 hr to fix

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 replaceNpm has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export async function replaceNpm() {
    console.info('If you use Linux, add this to your .zshrc or .bashrc:');
    console.info('-----------------------------------------------------');
    console.info(`replacenpm() {
  alias realnpm=$(which npm)
Severity: Minor
Found in src/lib/replace-npm.ts - About 1 hr to fix

    Function install has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    export async function* install(
        packages: string[],
        informedOptions: InstallOptions,
    ) {
        const options = prepareOptions(informedOptions);
    Severity: Minor
    Found in src/lib/install.ts - About 35 mins to fix

    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

    Severity
    Category
    Status
    Source
    Language