holidayextras/file-stream-rotator

View on GitHub

Showing 26 of 52 total issues

Function parseOptions has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    parseOptions(options) {
        var _a, _b, _c, _d;
        let config = {};
        config.options = DefaultOptions_1.default.fileStreamRotatorOptions(options);
        config.fileOptions = DefaultOptions_1.default.fileOptions((_a = options.file_options) !== null && _a !== void 0 ? _a : {});
Severity: Minor
Found in lib/FileStreamRotator.js - About 5 hrs 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 constructor has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    constructor(settings, lastEntry) {
        var _a;
        this.currentSize = 0;
        this.lastDate = "";
        this.fileIndx = 0;
Severity: Minor
Found in lib/Rotator.js - About 4 hrs 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 constructor has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    constructor(settings: RotationSettings, lastEntry?: AuditEntry){
        this.settings = settings
        // if (!this.settings.format) {
        //     this.settings.frequency = Frequency.none
        //     Logger.log("[FileStreamRotator] Changing type to none as date format is missing");
Severity: Minor
Found in src/Rotator.ts - About 4 hrs 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 parseOptions has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    private parseOptions(options: Partial<FileStreamRotatorOptions>): FileStreamRotatorConfig {
        let config: FileStreamRotatorConfig = {}
        config.options = DefaultOptions.fileStreamRotatorOptions(options)
        config.fileOptions = DefaultOptions.fileOptions(options.file_options ?? {})

Severity: Minor
Found in src/FileStreamRotator.ts - About 3 hrs 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 parseOptions has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    parseOptions(options) {
        var _a, _b, _c, _d;
        let config = {};
        config.options = DefaultOptions_1.default.fileStreamRotatorOptions(options);
        config.fileOptions = DefaultOptions_1.default.fileOptions((_a = options.file_options) !== null && _a !== void 0 ? _a : {});
Severity: Major
Found in lib/FileStreamRotator.js - About 2 hrs to fix

    Function parseOptions has 69 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private parseOptions(options: Partial<FileStreamRotatorOptions>): FileStreamRotatorConfig {
            let config: FileStreamRotatorConfig = {}
            config.options = DefaultOptions.fileStreamRotatorOptions(options)
            config.fileOptions = DefaultOptions.fileOptions(options.file_options ?? {})
    
    
    Severity: Major
    Found in src/FileStreamRotator.ts - About 2 hrs to fix

      Function constructor has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          constructor(settings, lastEntry) {
              var _a;
              this.currentSize = 0;
              this.lastDate = "";
              this.fileIndx = 0;
      Severity: Major
      Found in lib/Rotator.js - About 2 hrs to fix

        Function constructor has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            constructor(settings: RotationSettings, lastEntry?: AuditEntry){
                this.settings = settings
                // if (!this.settings.format) {
                //     this.settings.frequency = Frequency.none
                //     Logger.log("[FileStreamRotator] Changing type to none as date format is missing");
        Severity: Major
        Found in src/Rotator.ts - About 2 hrs to fix

          Function addLog has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              addLog(name) {
                  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("audit log missing");
                      return;
          Severity: Minor
          Found in lib/AuditManager.js - About 2 hrs 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 addLog has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              addLog(name: string) {
                  if (!this.config.keepSettings || this.config.keepSettings?.amount == 0 || !this.config.auditFilename || this.config.auditFilename == "") {
                      Logger.verbose("audit log missing")
                      return
                  }
          Severity: Minor
          Found in src/AuditManager.ts - About 1 hr 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 getDateString has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              getDateString(date) {
                  let _date = date || new Date();
                  let components = Rotator.getDateComponents(_date, this.settings.utc);
                  let format = this.settings.format;
                  if (format) {
          Severity: Minor
          Found in lib/Rotator.js - About 1 hr 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 addLog has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              addLog(name) {
                  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("audit log missing");
                      return;
          Severity: Minor
          Found in lib/AuditManager.js - About 1 hr to fix

            Function addLog has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                addLog(name: string) {
                    if (!this.config.keepSettings || this.config.keepSettings?.amount == 0 || !this.config.auditFilename || this.config.auditFilename == "") {
                        Logger.verbose("audit log missing")
                        return
                    }
            Severity: Minor
            Found in src/AuditManager.ts - About 1 hr to fix

              Function createCurrentSymLink has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  createCurrentSymLink(logfile) {
                      var _a, _b;
                      if (!logfile) {
                          return;
                      }
              Severity: Minor
              Found in lib/FileStreamRotator.js - About 1 hr 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 getDateString has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  getDateString(date?: Date): string {
                      let _date: Date = date || new Date()
              
                      let components: DateComponents = Rotator.getDateComponents(_date, this.settings.utc)
              
              
              Severity: Minor
              Found in src/Rotator.ts - About 1 hr 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 getDateString has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  getDateString(date?: Date): string {
                      let _date: Date = date || new Date()
              
                      let components: DateComponents = Rotator.getDateComponents(_date, this.settings.utc)
              
              
              Severity: Minor
              Found in src/Rotator.ts - About 1 hr to fix

                Function createCurrentSymLink has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    createCurrentSymLink(logfile) {
                        var _a, _b;
                        if (!logfile) {
                            return;
                        }
                Severity: Minor
                Found in lib/FileStreamRotator.js - About 1 hr to fix

                  Function rotate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      rotate(force = false) {
                          var _a;
                          let oldFile = this.currentFile;
                          this.rotator.rotate(force);
                          this.currentFile = this.rotator.getNewFilename();
                  Severity: Minor
                  Found in lib/FileStreamRotator.js - About 55 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 write has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      write(str, encoding) {
                          if (this.fs) {
                              if (this.rotator.shouldRotate()) {
                                  this.rotate();
                              }
                  Severity: Minor
                  Found in lib/FileStreamRotator.js - About 45 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 extractParam has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      static extractParam(param, lowercase = true) {
                          let letter = param.toString().match(/(\w)$/);
                          let rtn = { number: 0 };
                          if ((letter === null || letter === void 0 ? void 0 : letter.length) == 2) {
                              rtn.letter = letter[1].toLowerCase();
                  Severity: Minor
                  Found in lib/DefaultOptions.js - About 45 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