koss-lebedev/bootstrap-cron-picker

View on GitHub

Showing 16 of 16 total issues

File cron-picker.js has 319 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function ($) {

    class CronPicker {

        constructor(wrapper, hostControl, options) {
Severity: Minor
Found in src/cron-picker.js - About 3 hrs to fix

    Function _buildMonthlyFilter has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            _buildMonthlyFilter() {
                const self = this;
                const dayButton = this._buildFilterButton('day');
                const weekDayButton = this._buildFilterButton('weekday');
    
    
    Severity: Major
    Found in src/cron-picker.js - About 2 hrs to fix

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

                  const monthRepeaterSelect = $('<select>', {
                      html: CronPicker._buildOptions(12, 1),
                      class: 'form-control cron-picker-month-repeater'
                  }).on('change', function() {
                      self.state.monthRepeater = this.value;
      Severity: Major
      Found in src/cron-picker.js and 1 other location - About 2 hrs to fix
      src/cron-picker.js on lines 58..64

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 75.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

                  const daySelect = $('<select>', {
                      html: CronPicker._buildOptions(31, 1),
                      class: 'form-control cron-picker-day-number'
                  }).on('change', function() {
                      self.state.dayNumber = this.value;
      Severity: Major
      Found in src/cron-picker.js and 1 other location - About 2 hrs to fix
      src/cron-picker.js on lines 66..72

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 75.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function parse has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      QuartzCronFormatter.parse = function (cron) {
          const state = {};
          const parts = cron.split(' ');
          if (parts.length !== 7) {
              console.warn('Invalid cron expression. Skip parsing...');
      Severity: Minor
      Found in src/quartz-cron-formatter.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

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

                  const ordinalitySelect = $('<select>', {
                      class: 'form-control cron-picker-ord-select',
                      html: this._buildOrdinalityOptions()
                  }).on('change', function() {
                      self.state.ordCondition = this.value;
      Severity: Major
      Found in src/cron-picker.js and 1 other location - About 1 hr to fix
      src/cron-picker.js on lines 94..100

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 73.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

                  const dayOfWeekSelect = $('<select>', {
                      class: 'form-control cron-picker-dow-select',
                      html: this._buildDaysOfWeekOptions()
                  }).on('change', function() {
                      self.state.dayOfWeek = this.value;
      Severity: Major
      Found in src/cron-picker.js and 1 other location - About 1 hr to fix
      src/cron-picker.js on lines 86..92

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 73.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function _updateUI has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              _updateUI() {
                  // Set controls value based on current state
      
                  this.wrapper.find('li').removeClass('active');
                  this.wrapper.find(`[data-type=${this.state.type}]`).addClass('active');
      Severity: Minor
      Found in src/cron-picker.js - About 1 hr to fix

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

        StandardCronFormatter.parse = function (cron) {
            const state = {};
            const parts = cron.split(' ');
            if (parts.length !== 5 && parts.length !== 6) {
                console.warn('Invalid cron expression. Skip parsing...');
        Severity: Minor
        Found in src/standard-cron-formatter.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

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

                case "Weekly":
                    const dow = state.daysOfWeek.sort().join(',');
                    return `${state.minutes} ${state.hours} * * ${dow}`;
        Severity: Major
        Found in src/standard-cron-formatter.js and 1 other location - About 1 hr to fix
        src/quartz-cron-formatter.js on lines 47..49

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 58.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

                case "Weekly":
                    const dow = state.daysOfWeek.sort().join(',');
                    return `0 ${state.minutes} ${state.hours} ? * ${dow} *`;
        Severity: Major
        Found in src/quartz-cron-formatter.js and 1 other location - About 1 hr to fix
        src/standard-cron-formatter.js on lines 40..42

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 58.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

        QuartzCronFormatter.parse = function (cron) {
            const state = {};
            const parts = cron.split(' ');
            if (parts.length !== 7) {
                console.warn('Invalid cron expression. Skip parsing...');
        Severity: Minor
        Found in src/quartz-cron-formatter.js - About 1 hr to fix

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

                  } else if (parts[3] == '*' && parts[4] !== '*') {
          
                      // weekly
                      state.type = 'Weekly';
                      state.daysOfWeek = parts[4] === '' ? [] : parts[4].split(',');
          Severity: Major
          Found in src/standard-cron-formatter.js and 1 other location - About 1 hr to fix
          src/quartz-cron-formatter.js on lines 17..38

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 55.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                  } else if (parts[4] == '*' && parts[5] !== '?') {
          
                      // weekly
                      state.type = 'Weekly';
                      state.daysOfWeek = parts[5] === '' ? [] : parts[5].split(',');
          Severity: Major
          Found in src/quartz-cron-formatter.js and 1 other location - About 1 hr to fix
          src/standard-cron-formatter.js on lines 17..31

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 55.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                      if (this.state.dayFilter == 'day') {
                          this.wrapper.find('.cron-picker-day-type-filter').removeClass('hidden');
                          this.wrapper.find('.cron-picker-weekday-type-filter').addClass('hidden');
                      } else {
          Severity: Minor
          Found in src/cron-picker.js and 1 other location - About 40 mins to fix
          src/cron-picker.js on lines 336..339

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 49.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

                      } else {
                          this.wrapper.find('.cron-picker-day-type-filter').addClass('hidden');
                          this.wrapper.find('.cron-picker-weekday-type-filter').removeClass('hidden');
                      }
          Severity: Minor
          Found in src/cron-picker.js and 1 other location - About 40 mins to fix
          src/cron-picker.js on lines 333..336

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 49.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language