rschmukler/agenda

View on GitHub

Showing 35 of 81 total issues

Function connect has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    async connect(): Promise<void> {
        const db = await this.createConnection();
        log('successful connection to MongoDB', db.options);

        const collection = this.connectOptions.db?.collection || 'agendaJobs';
Severity: Minor
Found in src/JobDbRepository.ts - About 1 hr to fix

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

    export const computeFromInterval = (attrs: IJobParameters<any>): Date => {
        const previousNextRunAt = attrs.nextRunAt || new Date();
        log('[%s:%s] computing next run via interval [%s]', attrs.name, attrs._id, attrs.repeatInterval);
    
        const lastRun = dateForTimezone(attrs.lastRunAt || new Date(), attrs.repeatTimezone);
    Severity: Minor
    Found in src/utils/nextRunAt.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 runJob has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async runJob() {
            const definition = this.agenda.definitions[this.attrs.name];
    
            if (!definition) {
                log('[%s:%s] has no definition, can not run', this.attrs.name, this.attrs._id);
    Severity: Minor
    Found in src/Job.ts - About 1 hr to fix

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

          async saveJobState(job: Job<any>): Promise<void> {
              const id = job.attrs._id;
              const $set = {
                  lockedAt: (job.attrs.lockedAt && new Date(job.attrs.lockedAt)) || undefined,
                  nextRunAt: (job.attrs.nextRunAt && new Date(job.attrs.nextRunAt)) || undefined,
      Severity: Minor
      Found in src/JobDbRepository.ts - 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 jobQueueFilling has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          private async jobQueueFilling(name: string): Promise<void> {
              this.isJobQueueFilling.set(name, true);
      
              try {
                  // Don't lock because of a limit we have set (lockLimit, etc)
      Severity: Minor
      Found in src/JobProcessor.ts - 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 highlightActiveHash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function highlightActiveHash(event) {
        var oldUrl, oldSubSectionElement;
      
        // check for and remove old hash active state
        if (event && event.originalEvent.oldURL) {
      Severity: Minor
      Found in docs/agenda/3.1.0/scripts/pagelocation.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 highlightActiveHash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function highlightActiveHash(event) {
        var oldUrl, oldSubSectionElement;
      
        // check for and remove old hash active state
        if (event && event.originalEvent.oldURL) {
      Severity: Minor
      Found in docs/agenda/4.0.1/scripts/pagelocation.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 highlightActiveHash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function highlightActiveHash(event) {
        var oldUrl, oldSubSectionElement;
      
        // check for and remove old hash active state
        if (event && event.originalEvent.oldURL) {
      Severity: Minor
      Found in docs/agenda/1.0.3/scripts/pagelocation.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 highlightActiveHash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function highlightActiveHash(event) {
        var oldUrl, oldSubSectionElement;
      
        // check for and remove old hash active state
        if (event && event.originalEvent.oldURL) {
      Severity: Minor
      Found in docs/agenda/2.2.0/scripts/pagelocation.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 highlightActiveHash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function highlightActiveHash(event) {
        var oldUrl, oldSubSectionElement;
      
        // check for and remove old hash active state
        if (event && event.originalEvent.oldURL) {
      Severity: Minor
      Found in docs/agenda/2.0.0/scripts/pagelocation.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 highlightActiveHash has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function highlightActiveHash(event) {
        var oldUrl, oldSubSectionElement;
      
        // check for and remove old hash active state
        if (event && event.originalEvent.oldURL) {
      Severity: Minor
      Found in docs/agenda/4.2.0/scripts/pagelocation.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 toJson has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          toJson(): IJobParameters {
              const result = {} as IJobParameters;
      
              for (const key of Object.keys(this.attrs)) {
                  if (Object.hasOwnProperty.call(this.attrs, key)) {
      Severity: Minor
      Found in src/Job.ts - 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

      Avoid too many return statements within this function.
      Open

                              return;
      Severity: Major
      Found in src/JobProcessor.ts - About 30 mins to fix

        Function run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            async run(): Promise<void> {
                this.attrs.lastRunAt = new Date();
                log(
                    '[%s:%s] setting lastRunAt to: %s',
                    this.attrs.name,
        Severity: Minor
        Found in src/Job.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 connect has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            async connect(): Promise<void> {
                const db = await this.createConnection();
                log('successful connection to MongoDB', db.options);
        
                const collection = this.connectOptions.db?.collection || 'agendaJobs';
        Severity: Minor
        Found in src/JobDbRepository.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