ruhley/angular-color-picker

View on GitHub

Showing 22 of 22 total issues

File controller.js has 829 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import tinycolor from 'tinycolor2';

export default class AngularColorPickerController {
    constructor(_$scope, _$element, _$document, _$timeout, _ColorPickerOptions) {
        // set angular injected variables
Severity: Major
Found in src/scripts/controller.js - About 1 day to fix

    AngularColorPickerController has 57 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class AngularColorPickerController {
        constructor(_$scope, _$element, _$document, _$timeout, _ColorPickerOptions) {
            // set angular injected variables
            this.$scope = _$scope;
            this.$element = _$element;
    Severity: Major
    Found in src/scripts/controller.js - About 1 day to fix

      Function template has 87 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function template($templateCache) {
          $templateCache.put('template/color-picker/directive.html',
              '<div class="color-picker-wrapper" ng-class="{' +
                  '\'color-picker-disabled\': AngularColorPickerController.options.disabled,' +
                  '\'color-picker-swatch-only\': AngularColorPickerController.options.swatchOnly,' +
      Severity: Major
      Found in src/scripts/template.js - About 3 hrs to fix

        Function initWatchers has 62 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            initWatchers() {
        
                // ngModel
        
                this.$scope.$watch('AngularColorPickerController.internalNgModel', this.watchInternalNgModel.bind(this));
        Severity: Major
        Found in src/scripts/controller.js - About 2 hrs to fix

          Function initMouseEvents has 55 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              initMouseEvents() {
                  const eventHandlers = {
                      mouseDown: this.onMouseDown.bind(this),
                      mouseUp: this.onMouseUp.bind(this),
                      mouseMove: this.onMouseMove.bind(this),
          Severity: Major
          Found in src/scripts/controller.js - About 2 hrs to fix

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

                constructor() {
                    return {
                        // input attributes
                        id: undefined,
                        name: undefined,
            Severity: Major
            Found in src/scripts/options-service.js - About 2 hrs to fix

              Function setupApi has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  setupApi() {
                      if (!this.api) {
                          this.api = {};
                      }
              
              
              Severity: Minor
              Found in src/scripts/controller.js - About 1 hr to fix

                Function update has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    update() {
                        if (!this.areAllValuesSet()) {
                            return false;
                        }
                
                
                Severity: Minor
                Found in src/scripts/controller.js - About 1 hr to fix

                  Function setupApi has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      setupApi() {
                          if (!this.api) {
                              this.api = {};
                          }
                  
                  
                  Severity: Minor
                  Found in src/scripts/controller.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 getColorValue has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      getColorValue(dynamicValues = true, includeOpacity = true) {
                          let value = {
                              h: this.hue,
                              s: dynamicValues ? `${this.saturation}%` : '100%',
                              v: dynamicValues ? `${this.lightness}%`: '100%'
                  Severity: Minor
                  Found in src/scripts/controller.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 checkDirty has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      checkDirty(color) {
                          // check dirty/pristine state
                          if (this.hasOwnProperty('initialNgModel')) {
                              if (color === this.initialNgModel) {
                                  if (typeof this.$scope.control[0].$setPristine === 'function') {
                  Severity: Minor
                  Found in src/scripts/controller.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 offset has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      offset(el) {
                          var docElem, win, rect, doc, elem = el[0];
                  
                          if (!elem) {
                              return;
                  Severity: Minor
                  Found in src/scripts/controller.js - About 1 hr to fix

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

                        updateHueBackground(color) {
                            var el = this.find('.color-picker-hue .color-picker-overlay');
                            var direction = this.options.horizontal ? 'left' : 'top';
                    
                            var zero_sixths = this.getColorValue(this.options.dynamicHue);
                    Severity: Minor
                    Found in src/scripts/controller.js - About 1 hr to fix

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

                          valueUpdate(type) {
                              if (this[type] !== undefined) {
                                  if (type === 'saturation') {
                                      this[`${type}Pos`] = this[type];
                                  } else {
                      Severity: Minor
                      Found in src/scripts/controller.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 setColorValue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          setColorValue(color) {
                              let noMouseEvents = !this.anyMouseEvents();
                              let hsl = this.options.round ? color.toHsl() : color.toHsv();
                      
                              if (noMouseEvents || this.hueMouse) {
                      Severity: Minor
                      Found in src/scripts/controller.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 mergeOptions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          mergeOptions(options, defaultOptions) {
                              for (var attr in defaultOptions) {
                                  if (defaultOptions.hasOwnProperty(attr)) {
                                      if (!options || !options.hasOwnProperty(attr)) {
                                          options[attr] = defaultOptions[attr];
                      Severity: Minor
                      Found in src/scripts/controller.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 update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          update() {
                              if (!this.areAllValuesSet()) {
                                  return false;
                              }
                      
                      
                      Severity: Minor
                      Found in src/scripts/controller.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 find has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          find(selector) {
                              var context = this.wrapper ? this.wrapper[0] : this.$element[0],
                                  results = [],
                                  nodeType;
                      
                      
                      Severity: Minor
                      Found in src/scripts/controller.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 watchNgModelSet has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          watchNgModelSet(newValue) {
                              if (newValue !== undefined && newValue !== null) {
                                  var color = tinycolor(newValue);
                                  var isValid = this.isColorValid(color);
                      
                      
                      Severity: Minor
                      Found in src/scripts/controller.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 offset has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          offset(el) {
                              var docElem, win, rect, doc, elem = el[0];
                      
                              if (!elem) {
                                  return;
                      Severity: Minor
                      Found in src/scripts/controller.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

                      Severity
                      Category
                      Status
                      Source
                      Language