rvalenciano/ngx-cron-jobs

View on GitHub

Showing 119 of 119 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

private numeral: Array<CronJobsSelectOption> = [
{value: 1, label: '1st'},
{value: 2, label: '2nd'},
{value: 3, label: '3rd'},
{value: 4, label: '4th'},
Severity: Major
Found in src/app/lib/services/data.service.ts and 1 other location - About 2 days to fix
src/app/lib/fixture.spec.ts on lines 11..43

Identical blocks of code found in 2 locations. Consider refactoring.
Open

export const numeral = [
{value: 1, label: '1st'},
{value: 2, label: '2nd'},
{value: 3, label: '3rd'},
{value: 4, label: '4th'},
Severity: Major
Found in src/app/lib/fixture.spec.ts and 1 other location - About 2 days to fix
src/app/lib/services/data.service.ts on lines 37..69

Similar blocks of code found in 2 locations. Consider refactoring.
Open

if (cron[0] === '*' && cron[1] === '*' && cron[2] === '*' && cron[3] === '*' && cron[4] === '*') {
frequency.baseFrequency = this.baseFrequency.minute; // every minute
} else if (cron[1] === '*' && cron[2] === '*' && cron[3] === '*' && cron[4] === '*') {
frequency.baseFrequency = this.baseFrequency.hour; // every hour
} else if (cron[2] === '*' && cron[3] === '*' && cron[4] === '*') {
Severity: Major
Found in src/app/lib/services/posix.service.ts and 1 other location - About 1 day to fix
src/app/lib/services/quartz.service.ts on lines 35..47

Similar blocks of code found in 2 locations. Consider refactoring.
Open

if (cron[1] === '*' && cron[2] === '*' && cron[3] === '*' && cron[4] === '*' && cron[5] === '?') {
frequency.baseFrequency = this.baseFrequency.minute; // every minute
} else if (cron[2] === '*' && cron[3] === '*' && cron[4] === '*' && cron[5] === '?') {
frequency.baseFrequency = this.baseFrequency.hour; // every hour
} else if (cron[3] === '*' && cron[4] === '*' && cron[5] === '?') {
Severity: Major
Found in src/app/lib/services/quartz.service.ts and 1 other location - About 1 day to fix
src/app/lib/services/posix.service.ts on lines 66..78

File cron-jobs.component.spec.ts has 444 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
 
import { CronJobsComponent } from './cron-jobs.component';
import { FormControl, ReactiveFormsModule } from '@angular/forms';
import * as fixtures from '../fixture.spec';
Severity: Minor
Found in src/app/lib/cron-jobs/cron-jobs.component.spec.ts - About 6 hrs to fix

    File posix.service.spec.ts has 409 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { TestBed, inject } from '@angular/core/testing';
     
    import { PosixService } from './posix.service';
    import { DataService } from './data.service';
    import Spy = jasmine.Spy;
    Severity: Minor
    Found in src/app/lib/services/posix.service.spec.ts - About 5 hrs to fix

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

      private _months: Array<CronJobsSelectOption> = [
      {value: 1, label: 'January'},
      {value: 2, label: 'February'},
      {value: 3, label: 'March'},
      {value: 4, label: 'April'},
      Severity: Major
      Found in src/app/lib/services/data.service.ts and 1 other location - About 5 hrs to fix
      src/app/lib/fixture.spec.ts on lines 45..58

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

      export const months = [
      {value: 1, label: 'January'},
      {value: 2, label: 'February'},
      {value: 3, label: 'March'},
      {value: 4, label: 'April'},
      Severity: Major
      Found in src/app/lib/fixture.spec.ts and 1 other location - About 5 hrs to fix
      src/app/lib/services/data.service.ts on lines 71..84

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      it('should return false if validation state equals to false on getIsInvalid call ' +
      'and no call getIsInvalid if validate.validate is false', fakeAsync(() => {
      testComponent.cronValidate = {
      validate: false
      };
      Severity: Major
      Found in src/app/lib/cron-jobs/cron-jobs.component.spec.ts and 1 other location - About 5 hrs to fix
      src/app/lib/cron-jobs/cron-jobs.component.spec.ts on lines 397..411

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      it('should return false if validation state equals to false on getIsValid call ' +
      'and no call getValid if validate.validate is false', fakeAsync(() => {
      testComponent.cronValidate = {
      validate: false
      };
      Severity: Major
      Found in src/app/lib/cron-jobs/cron-jobs.component.spec.ts and 1 other location - About 5 hrs to fix
      src/app/lib/cron-jobs/cron-jobs.component.spec.ts on lines 413..427

      File quartz.service.spec.ts has 375 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { TestBed, inject } from '@angular/core/testing';
       
      import { QuartzService } from './quartz.service';
      import { DataService } from './data.service';
      import * as fixture from '../fixture.spec';
      Severity: Minor
      Found in src/app/lib/services/quartz.service.spec.ts - About 5 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        it('should render correct selects on baseFrequency set to 4', fakeAsync(() => {
        tick();
        orgComponent.cronJobsForm.get('baseFrequency').setValue('4');
        fixture.detectChanges();
         
         
        Severity: Major
        Found in src/app/lib/cron-jobs/cron-jobs.component.spec.ts and 1 other location - About 4 hrs to fix
        src/app/lib/cron-jobs/cron-jobs.component.spec.ts on lines 542..552

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        it('should render correct selects on baseFrequency set to 5', fakeAsync(() => {
        tick();
        orgComponent.cronJobsForm.get('baseFrequency').setValue('5');
        fixture.detectChanges();
         
         
        Severity: Major
        Found in src/app/lib/cron-jobs/cron-jobs.component.spec.ts and 1 other location - About 4 hrs to fix
        src/app/lib/cron-jobs/cron-jobs.component.spec.ts on lines 530..540

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        it('should return default frequency on fromCron call with incorrect in length cron expression', () => {
        const expWrongOne = '0 * * * ?';
        const expWrongTwo = '0 * * * 1 2 3 ?';
        const expected = {
        baseFrequency: fixture.baseFrequency[0].value,
        Severity: Major
        Found in src/app/lib/services/quartz.service.spec.ts and 1 other location - About 4 hrs to fix
        src/app/lib/services/posix.service.spec.ts on lines 68..82

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        it('should return default frequency on fromCron call with incorrect in length cron expression', () => {
        const expWrongOne = '* * 11 1';
        const expWrongTwo = '* * 11 1 1 3 4,12, 1 *';
        const expected = {
        baseFrequency: fixture.baseFrequency[0].value,
        Severity: Major
        Found in src/app/lib/services/posix.service.spec.ts and 1 other location - About 4 hrs to fix
        src/app/lib/services/quartz.service.spec.ts on lines 24..38

        Function setCron has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        setCron(value: CronJobsFrequency) {
        const cron = ['*', '*', '*', '*', '*'];
         
        if (value && value.baseFrequency) {
        if (value.baseFrequency >= this.baseFrequency.hour) {
        Severity: Minor
        Found in src/app/lib/services/posix.service.ts - About 3 hrs to fix

        Function setCron has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        setCron(newValue: CronJobsFrequency) {
        const cron = ['0', '*', '*', '*', '*', '?'];
         
        if (newValue && newValue.baseFrequency) {
        if (newValue.baseFrequency >= this.baseFrequency.hour) {
        Severity: Minor
        Found in src/app/lib/services/quartz.service.ts - About 3 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        it('should return if validation state on getIsValid call and call getValid if validate.validate is set to true', fakeAsync(() => {
        testFixture.detectChanges();
        const spy = spyOn(component, 'getValid').and.callThrough();
         
        tick();
        Severity: Major
        Found in src/app/lib/cron-jobs/cron-jobs.component.spec.ts and 1 other location - About 3 hrs to fix
        src/app/lib/cron-jobs/cron-jobs.component.spec.ts on lines 385..395

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        it('should return if validation state on getIsInvalid call and call getValid if validate.validate is set to true', fakeAsync(() => {
        testFixture.detectChanges();
        const spy = spyOn(component, 'getValid').and.callThrough();
         
        tick();
        Severity: Major
        Found in src/app/lib/cron-jobs/cron-jobs.component.spec.ts and 1 other location - About 3 hrs to fix
        src/app/lib/cron-jobs/cron-jobs.component.spec.ts on lines 373..383

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        private daysOfWeekQuartz: Array<CronJobsSelectOption> = [
        {value: 1, label: 'Sunday'},
        {value: 2, label: 'Monday'},
        {value: 3, label: 'Tuesday'},
        {value: 4, label: 'Wednesday'},
        Severity: Major
        Found in src/app/lib/services/data.service.ts and 2 other locations - About 3 hrs to fix
        src/app/lib/services/data.service.ts on lines 17..25
        src/app/lib/services/data.service.ts on lines 86..94
        Severity
        Category
        Status
        Source
        Language