Showing 163 of 559 total issues
Function createReplacer
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected async createReplacer(context: HtmlRR0SsgContext): Promise<DomReplacer<HTMLImageElement>> {
return {
replace: async (imgEl: HTMLImageElement): Promise<HTMLImageElement> => {
const src = imgEl.src;
const imgParentEl = imgEl.parentElement;
File PeopleDirectoryStep.ts
has 256 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { Occupation } from "./Occupation"
import { Time } from "../time/Time"
import { KnownPeople, People } from "./People"
import { promise as glob } from "glob-promise"
import { HtmlRR0SsgContext } from "../RR0SsgContext"
File sw.js
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
const version = '0.1.0'
let serverUrl
// Cache IDs
let coreID = `core_${version}`
let pageID = `pages_${version}`
Function processDirs
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected async processDirs(context: HtmlRR0SsgContext, dirNames: string[]): Promise<void> {
let peopleList = await this.service.getPeopleFromDirs(context, dirNames)
if (this.filterOccupations.length > 0) {
peopleList = peopleList.filter((p: People) => p.occupations.some(o => this.filterOccupations.includes(o)))
}
Function replacement
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
async replacement(context: HtmlRR0SsgContext, original: HTMLTimeElement): Promise<HTMLElement> {
let replacement: HTMLElement | undefined
if (original.dateTime) { // Already done?
replacement = original
} else {
- Read upRead up
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 initializeTable
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
neuralNetworkCalculationViz.prototype.initializeTable = function (trainingSet) {
var viz = this
var table = d3.select(this.tableElement)
Function replace
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
replace: async (imgEl: HTMLImageElement): Promise<HTMLImageElement> => {
const src = imgEl.src;
const imgParentEl = imgEl.parentElement;
if (imgParentEl.tagName === 'FIGURE') {
const captionEl = imgParentEl.querySelector('figcaption');
Function build
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
static build(context: RR0SsgContext, print = true): string {
const time = context.time
const printOptions: Intl.DateTimeFormatOptions = {}
const date = new Date(undefined, undefined, undefined)
const year = time.getYear()
Function getPeopleFromDir
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getPeopleFromDir(context: RR0SsgContext, dirName: string): Promise<People[]> {
let peopleList: People[] = []
const fileSpec = `/people*.json`
const files = await glob(`${dirName}${fileSpec}`)
for (const file of files) {
Function compute
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
compute: function (probable) {
var zerosCount = {};
var max = 0;
var questions = self.questions;
for (var q in questions) {
Function compute
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
compute: function (probable) {
var zerosCount = {}
var max = 0
var questions = self.questions
for (var q in questions) {
Function initializeErrorGraph
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
multiVariableNeuralNetworkTrainer.prototype.initializeErrorGraph = function () {
this.error_chart_history_x = 300; // How many error data points to show
this.error_chart_history_y = 100000; // How high the bar goes
this.error_history = [10000];
Function addSpeech
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
const addSpeech = (e, lang = e.lang, text = getText(e)) => {
if (!e.classList.contains(transformed)) {
e.classList.add(transformed)
const speechEl = document.createElement('button')
speechEl.className = 'speech'
- Read upRead up
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 graphLayerInputs
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function graphLayerInputs(layerInputsArray, layerNumber) {
var layerInputs = layerInputsArray[layerNumber], layerInputsObjects = []
Function multiVariableNeuralNetworkTrainer
has 15 arguments (exceeds 4 allowed). Consider refactoring. Open
var multiVariableNeuralNetworkTrainer = function (numberOfInputNodes,
svg_el, table_el,
dataPoints, labels,
weights, bias,
gradientDescentButton, gradientDescent10Button, gradientDescent100Button,
Function addSpeech
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
const addSpeech = (e, lang = e.lang, text = getText(e)) => {
if (!e.classList.contains(transformed)) {
e.classList.add(transformed)
const speechEl = document.createElement('button')
speechEl.className = 'speech'
Function getFromRow
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected async getFromRow(context: RR0SsgContext, row: Element): Promise<UfoSearchCase> {
const fieldsHeadings = Array.from(row.querySelectorAll("strong"))
const dateLabel = fieldsHeadings.find(heading => heading.textContent.indexOf("Date") >= 0)
const itemContext = context.clone()
const dateTime = itemContext.time.reset()
Function constructor
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
constructor(criteria = "", allowEmpty = true) {
this.criteria = criteria
this.allowEmpty = allowEmpty
this.matchers = []
const andCriterions = criteria.split("&")
- Read upRead up
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 thisSourceElement
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
protected thisSourceElement(context: HtmlRR0SsgContext, source: Source) {
const sourceEl = context.outputFile.document.createElement("span")
sourceEl.className = "source"
sourceEl.append(source.authors?.join(" & "), `: `)
const doc = context.outputFile.document
- Read upRead up
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 drawGraph
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
shallowNeuralNetworkGrapher.prototype.drawGraph = function () {
var grapher = this;
this.nodeRadius = 15;
this.weightNodeWidthRatio = 1.7;
// Let's calculate our coordinates for all the nodes
- Read upRead up
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"