cognitive-complexity-ts
Version:
This program analyses TypeScript and JavaScript code according to the [Cognitive Complexity metric](https://www.sonarsource.com/docs/CognitiveComplexity.pdf). It produces a JSON summary and a GUI for exploring the complexity of your codebase.
41 lines • 1.33 kB
JavaScript
import { showInTree, StickyTitle } from "./StickyTitle.js";
import { ToggleableBox } from "../box/ToggleableBox.js";
import { Score } from "../text/Score.js";
import { CopyText } from "../controls/CopyText.js";
import { concatFilePath } from "../../domain/path.js";
export class File {
constructor(file, children) {
this.children = children;
this.depth = file.depth;
const fullPath = concatFilePath(file.path, file.name);
this.title = new StickyTitle([
file.name,
CopyText(fullPath),
], file.depth);
this.box = new ToggleableBox([
this.title.dom,
Score(file.score),
], false, () => this.scrollIntoView());
this.box.changeHideableContent(() => this.children.map(child => child.dom));
}
get dom() {
return this.box.dom;
}
scrollIntoView() {
showInTree(this.dom, this.depth);
}
setChildren(children) {
this.children = children;
this.box.changeHideableContent(() => this.children.map(child => child.dom));
}
setDepth(depth) {
if (this.depth !== depth) {
this.depth = depth;
this.title.setDepth(depth);
}
}
setOpenness(open) {
this.box.setOpenness(open);
}
}
//# sourceMappingURL=File.js.map