Showing 12 of 16 total issues
PackageJsonFile
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
export class PackageJsonFile extends FileBase {
// eslint-disable-next-line max-statements
private checkProperties () {
this.couldContainsSchema('https://json.schemastore.org/package')
Function getThanks
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private async getThanks (): Promise<Thanks[]> {
const list = [
new Thanks('Shields.io', 'https://shields.io', 'for the nice badges on top of this readme', this.fileContent.includes('shields')),
new Thanks('Travis-ci.com', 'https://travis-ci.com', 'for providing free continuous deployments', this.fileContent.includes('travis-ci')),
new Thanks('Github', 'https://github.com', 'for all their great work year after year, pushing OSS forward', this.fileContent.includes('github')),
Function findInFolder
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export async function findInFolder (folderPath: string, pattern: Readonly<RegExp>, ignoredInput: readonly string[] = ['node_modules', '.git'], count = 0) {
const filePaths = await readDirectoryAsync(folderPath)
const matches: string[] = []
let ignored = arrayUnique(ignoredInput)
if (filePaths.includes('.gitignore')) {
- 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 shouldContains
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public shouldContains (name: string, regex?: Readonly<RegExp>, nbMatchExpected = defaultAmount, willJustWarn = false, helpMessage = '', canFix = false): boolean {
// eslint-disable-next-line security/detect-non-literal-regexp
const regexp = regex ?? new RegExp(name, 'u')
const isOk = this.checkContains(regexp, nbMatchExpected)
const willFix = this.canFix && canFix && !isOk
- 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 checkCompilerOptions
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private checkCompilerOptions (): void {
/* c8 ignore next */
if (this.fileContentObject === undefined) { log.error('cannot check compiler options without file content'); return }
const json = this.fileContentObject
let isOk = this.couldContains('an include section', /"include"/u, 1, undefined, true)
- 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 augmentDataWithPackageJson
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export async function augmentDataWithPackageJson (folderPath: string, dataSource: Readonly<ProjectData>) {
const data = new ProjectData(dataSource)
if (!await fileExists(path.join(folderPath, 'package.json'))) {
log.debug('cannot augment, no package.json found in', folderPath)
return data
- 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 augmentDataWithPackageJson
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function augmentDataWithPackageJson (folderPath: string, dataSource: Readonly<ProjectData>) {
const data = new ProjectData(dataSource)
if (!await fileExists(path.join(folderPath, 'package.json'))) {
log.debug('cannot augment, no package.json found in', folderPath)
return data
Function check
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export async function check ({ canFailStop = false, canFix = false, canForce = false, canThrow = true, data, folderPath }: Readonly<CheckOptions>) {
const folders = await getProjectFolders(folderPath)
let passed: string[] = []
let warnings: string[] = []
let failed: string[] = []
- 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 checkThanks
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private async checkThanks (): Promise<void> {
const hasSection = this.couldContains('a thanks section', /## Thanks/u)
if (!hasSection) return
const thanks = await this.getThanks()
for (const thank of thanks) {
- 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 checkBadgesRecommended
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private checkBadgesRecommended (): void {
const badges = this.getBadgesRecommended()
for (const badge of badges) {
const message = `${badge.expected ? 'a' : 'no'} "${badge.label}" badge`
// eslint-disable-next-line security/detect-non-literal-regexp
- 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 checkScripts
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private checkScripts () {
this.checkScriptsTs()
this.shouldContains('a script section', this.regexForObjectProp('scripts'))
this.checkScriptsPrePost()
if (this.fileContent.includes('watchlist')) this.couldContains('watchlist eager param', /-eager --/u, 1, 'like watchlist src tests -eager -- pnpm test')
- 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 detectContext
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private async detectContext (): Promise<{ fileName: string; hasTsFile: boolean }> {
const hasJsFile = await this.fileExists('tailwind.config.js')
const hasTsFile = await this.fileExists('tailwind.config.ts')
const hasMjsFile = await this.fileExists('tailwind.config.mjs')
/* c8 ignore next 2 */
- 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"