holidayextras/file-stream-rotator

View on GitHub

Showing 26 of 52 total issues

Function getInstance has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    static getInstance(verbose, debug) {
        if (!Logger.instance) {
            Logger.instance = new Logger();
            Logger.instance.isVerbose = verbose !== null && verbose !== void 0 ? verbose : false;
            Logger.instance.allowDebug = debug !== null && debug !== void 0 ? debug : false;
Severity: Minor
Found in lib/helper.js - About 35 mins to fix

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 loadLog has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    loadLog() {
        var _a;
        if (!this.config.keepSettings || ((_a = this.config.keepSettings) === null || _a === void 0 ? void 0 : _a.amount) == 0 || !this.config.auditFilename || this.config.auditFilename == "") {
            helper_1.Logger.verbose("no existing audit settings found", this.config);
            return;
Severity: Minor
Found in lib/AuditManager.js - About 35 mins to fix

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 removeLog has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    removeLog(logEntry) {
        if (logEntry.hash === crypto.createHash(this.config.hashType).update(logEntry.name + "LOG_FILE" + logEntry.date).digest("hex")) {
            try {
                if (fs.existsSync(logEntry.name)) {
                    helper_1.Logger.debug("removing log file", logEntry.name);
Severity: Minor
Found in lib/AuditManager.js - About 25 mins to fix

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 createCurrentSymLink has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private createCurrentSymLink(logfile?: string) {
        if (!logfile) {
            return
        }
        let symLinkName = this.config.options?.symlink_name ?? "current.log"
Severity: Minor
Found in src/FileStreamRotator.ts - About 25 mins to fix

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 rotate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    rotate(force: boolean = false) {
        let oldFile = this.currentFile
        this.rotator.rotate(force)
        this.currentFile = this.rotator.getNewFilename()

Severity: Minor
Found in src/FileStreamRotator.ts - About 25 mins to fix

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 removeLog has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private removeLog(logEntry: AuditEntry){
        if(logEntry.hash === crypto.createHash(this.config.hashType).update(logEntry.name + "LOG_FILE" + logEntry.date).digest("hex")){
            try{
                if (fs.existsSync(logEntry.name)) {
                    Logger.debug("removing log file", logEntry.name)
Severity: Minor
Found in src/AuditManager.ts - About 25 mins to fix

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

Severity
Category
Status
Source
Language