Skip to content

Commit

Permalink
fix: missing ignore config handling
Browse files Browse the repository at this point in the history
In case ignoredByPath and ignoredBySource configurations are
missing treat it as empty ignore lists, pass everything.

Additionally log errors for ignore configuration entries that
throw errors when treated as JavaScript regular expressions.
  • Loading branch information
tkurki committed Oct 23, 2023
1 parent 66f0c0e commit 286c39b
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions src/influx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,20 +190,28 @@ export class SKInflux {
return ignoreStatus
}

ignoreStatusByConfig(path: string, sourceRef: string) {
const ignoredByPath = this.ignoredPaths.reduce<boolean>((acc, ignoredPathExp) => {
const ignoredPathRegExp = new RegExp(ignoredPathExp.replace(/\./g, '.'))
const ignored = ignoredPathRegExp.test(path)
ignored && this.logging.debug(`${path} from ${sourceRef} will be ignored by ${ignoredPathRegExp}`)
return acc || ignored
}, false)
const ignoredBySource = this.ignoredSources.reduce<boolean>((acc, ignoredSourceExp) => {
const ignoredSourceRegExp = new RegExp(ignoredSourceExp.replace(/\./g, '.'))
const ignored = ignoredSourceRegExp.test(sourceRef)
ignored && this.logging.debug(`${path} from ${sourceRef} will be ignored by ${ignoredSourceRegExp}`)
return acc || ignored
}, false)
return ignoredByPath || ignoredBySource
ignoreStatusByConfig(path: string, sourceRef: string): boolean {
try {
const ignoredByPath =
this.ignoredPaths?.reduce<boolean>((acc, ignoredPathExp) => {
const ignoredPathRegExp = new RegExp(ignoredPathExp.replace(/\./g, '.'))
const ignored = ignoredPathRegExp.test(path)
ignored && this.logging.debug(`${path} from ${sourceRef} will be ignored by ${ignoredPathRegExp}`)
return acc || ignored
}, false) || false
const ignoredBySource =
this.ignoredSources?.reduce<boolean>((acc, ignoredSourceExp) => {
const ignoredSourceRegExp = new RegExp(ignoredSourceExp.replace(/\./g, '.'))
const ignored = ignoredSourceRegExp.test(sourceRef)
ignored && this.logging.debug(`${path} from ${sourceRef} will be ignored by ${ignoredSourceRegExp}`)
return acc || ignored
}, false) || false
return ignoredByPath || ignoredBySource
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (e: any) {
this.logging.error(e.message)
return false
}
}
}

Expand Down

0 comments on commit 286c39b

Please sign in to comment.