Skip to content

Instantly share code, notes, and snippets.

@danielzazzali
Created December 18, 2025 22:53
Show Gist options
  • Select an option

  • Save danielzazzali/bbd87b74d2b943bdbad2bb11fe6944e5 to your computer and use it in GitHub Desktop.

Select an option

Save danielzazzali/bbd87b74d2b943bdbad2bb11fe6944e5 to your computer and use it in GitHub Desktop.
jtmetrics-errors

On P84-html-minifier-terser\cli.js we have the error:

Error traversing AST on metric function-coupling -> C:\Users\anais\OneDrive\Documentos\Github\Metrics2\repositories\P84-html-minifier-terser\cli.js: TypeError: Cannot read properties of undefined (reading 'camelCase')

And the code says:

import { camelCase, kebabCase } from 'change-case';
...
const param = programOptions[key === 'minifyURLs' ? 'minifyUrls' : camelCase(key)];

camelCase is an object from change-case which is a module that must be installed via npm, as is not part from the repo, jtmetrics cannot find the definition while searching for the metric "Function Coupling", thats why it fails.

On P84-html-minifier-terser\demo\main.js we have the error:

Error traversing AST on metric function-coupling -> C:\Users\anais\OneDrive\Documentos\Github\Metrics2\repositories\P84-html-minifier-terser\demo\main.js: TypeError: Cannot read properties of undefined (reading 'Boolean')

And the code says:

value = Boolean(option.checked);
...
checked: Boolean(yes)

Boolean function does not come from an import. Its a built-in global constructor/function provided by the JavaScript runtime, so we can't find the declaration while parsing/traversing the AST.

On P84-html-minifier-terser\src\htmlminifier.js we have the error:

Error traversing AST on metric function-coupling -> C:\Users\anais\OneDrive\Documentos\Github\Metrics2\repositories\P84-html-minifier-terser\src\htmlminifier.js: TypeError: Cannot read properties of undefined (reading 'decodeHTMLStrict')

And the code says:

import { decodeHTMLStrict, decodeHTML } from 'entities';
...
attrValue = decodeHTMLStrict(attrValue);

decodeHTMLStrict is an object from entities which a module that must be installed via npm, as is not part from the repo, jtmetrics cannot find the definition while searching for the metric "Function Coupling", thats why it fails.

On P84-html-minifier-terser\src\utils.js we have the error:

Error traversing AST on metric function-coupling -> C:\Users\anais\OneDrive\Documentos\Github\Metrics2\repositories\P84-html-minifier-terser\src\utils.js: TypeError: Cannot read properties of undefined (reading 'asyncFn')

And the code says:

export async function replaceAsync(str, regex, asyncFn) {
  const promises = [];

  str.replace(regex, (match, ...args) => {
    const promise = asyncFn(match, ...args);
    promises.push(promise);
  });

  const data = await Promise.all(promises);
  return str.replace(regex, () => data.shift());
}

asyncFN is a callback used inside replaceAsync function, we are unable to track the definition of that function as jtmetrics only does static analisys.

On P84-html-minifier-terser\benchmarks\backtest.cjs we have the error:

Error traversing AST on metric function-coupling -> C:\Users\anais\OneDrive\Documentos\Github\Metrics2\repositories\P84-html-minifier-terser\benchmarks\backtest.cjs: TypeError: Cannot read properties of undefined (reading 'require')

And the code says:

...
const urls = require('./sites.json');
...

require function does not come from an import. Its a built-in global constructor/function provided by the JavaScript runtime, so we can't find the declaration while parsing/traversing the AST.

On P84-html-minifier-terser\benchmarks\benchmark.cjs we have the error:

Error traversing AST on metric function-coupling -> C:\Users\anais\OneDrive\Documentos\Github\Metrics2\repositories\P84-html-minifier-terser\benchmarks\benchmark.cjs: TypeError: Cannot read properties of undefined (reading 'done')

And the code says:

function run(tasks, done) {
  let i = 0;

  function callback() {
    if (i < tasks.length) {
      tasks[i++](callback);
    } else {
      done();
    }
  }

  callback();
}
...

done is a callback function, we are unable to track the definition of that function as jtmetrics only does static analisys.

On P84-html-minifier-terser\tests\cli.spec.js we have the error:

Error traversing AST on metric function-coupling -> C:\Users\anais\OneDrive\Documentos\Github\Metrics2\repositories\P84-html-minifier-terser\tests\cli.spec.js: TypeError: Cannot read properties of undefined (reading 'spawnSync')

And the code says:

import { spawnSync } from 'child_process';
...
const { stdout, stderr } = spawnSync('node', [cliPath, ...args], spawnOptions);

spawnSync is an object from child_process which an external node module, as is not part from the repo, jtmetrics cannot find the definition while searching for the metric "Function Coupling", thats why it fails.

On P84-html-minifier-terser\tests\minifier.spec.js we have the error:

Error traversing AST on metric function-coupling -> C:\Users\anais\OneDrive\Documentos\Github\Metrics2\repositories\P84-html-minifier-terser\tests\minifier.spec.js: TypeError: Cannot read properties of undefined (reading 'defaultFn')

And the code says:

test('canCollapseWhitespace and canTrimWhitespace hooks', async () => {
  function canCollapseAndTrimWhitespace(tagName, attrs, defaultFn) {
    if ((attrs || []).some(function (attr) { return attr.name === 'class' && attr.value === 'leaveAlone'; })) {
      return false;
    }
    return defaultFn(tagName, attrs);
  }
...

defaultFn is a callback function, we are unable to track the definition of that function as jtmetrics only does static analisys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment