Showing 4 of 11 total issues

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

window.onload = function() {
  var colorThief = new ColorThief();
  // var img_base = '/data/img/'; // get avatar from localhost
  var img_base = 'https://avatars2.githubusercontent.com/u/';
  var faces = document.getElementById('faces');
Severity: Major
Found in lib/faces.js - About 2 hrs to fix

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

    function rgbToHsl(c) { // https://stackoverflow.com/a/11923973/1148249
      var r = c[0]/255, g = c[1]/255, b = c[2]/255;
      var max = Math.max(r, g, b), min = Math.min(r, g, b);
      var h, s, l = (max + min) / 2;
    
    
    Severity: Minor
    Found in lib/faces.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

    Avoid deeply nested control flow statements.
    Open

                if (count[col[3]] === undefined || isNaN(count[col[3]])) {
                  count[col[3]] = 1;
                }
                else { count[col[3]] = count[col[3]] + 1; }
    Severity: Major
    Found in data/unique_learners.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if (count[col[3]] === undefined || isNaN(count[col[3]])) {
                    count[col[3]] = 1;
                  }
                  else { count[col[3]] = count[col[3]] + 1; }
      Severity: Major
      Found in data/unique.js - About 45 mins to fix
        Severity
        Category
        Status
        Source
        Language