crafatar/crafatar

View on GitHub

Showing 49 of 62 total issues

Function exports has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function(request, response, result) {
  // These headers are the same for every response
  var headers = {
    "Content-Type": result.body && result.type || "text/plain",
    "Content-Length": Buffer.from(result.body || "").length,
Severity: Minor
Found in lib/response.js - About 5 hrs 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 draw_model has 111 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exp.draw_model = function(rid, img, scale, overlay, is_body, slim, callback) {
  var canvas = cvs.createCanvas();
  canvas.width = scale * 20;
  canvas.height = scale * (is_body ? 45.1 : 18.5);

Severity: Major
Found in lib/renders.js - About 4 hrs to fix

    File helpers.js has 323 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var networking = require("./networking");
    var logging = require("./logging");
    var renders = require("./renders");
    var config = require("../config");
    var cache = require("./cache");
    Severity: Minor
    Found in lib/helpers.js - About 3 hrs to fix

      Function get_image_hash has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

      exp.get_image_hash = function(rid, userId, type, callback) {
        cache.get_details(userId, function(err, cache_details) {
          var cached_hash = null;
          if (cache_details !== null) {
            cached_hash = type === "skin" ? cache_details.skin : cache_details.cape;
      Severity: Minor
      Found in lib/helpers.js - About 3 hrs 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 extract_helm has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exp.extract_helm = function(rid, facefile, buffer, outname, callback) {
        lwip.open(buffer, "png", function(err, skin_img) {
          if (err) {
            callback(err);
          } else {
      Severity: Major
      Found in lib/skins.js - About 2 hrs to fix

        Function exports has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function(request, response, result) {
          // These headers are the same for every response
          var headers = {
            "Content-Type": result.body && result.type || "text/plain",
            "Content-Length": Buffer.from(result.body || "").length,
        Severity: Major
        Found in lib/response.js - About 2 hrs to fix

          Function requestHandler has 65 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function requestHandler(req, res) {
            req.url = new URL(decodeURI(req.url), 'http://' + req.headers.host);
            req.url.pathname = path.resolve('/', req.url.pathname);
            req.url.path_list = path_list(req.url.pathname);
            req.id = request_id();
          Severity: Major
          Found in lib/server.js - About 2 hrs to fix

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

            exp.get_from_options = function(rid, url, options, callback) {
              var is_session_req = config.server.sessions_rate_limit && url.startsWith(session_url);
            
              // This is to prevent being blocked by CloudFront for exceeding the rate limit
              if (is_session_req && req_count() >= config.server.sessions_rate_limit) {
            Severity: Major
            Found in lib/networking.js - About 2 hrs to fix

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

              module.exports = function(req, callback) {
                var raw_type = req.url.path_list[1] || "";
                var rid = req.id;
                var body = raw_type === "body";
                var userId = (req.url.path_list[2] || "").split(".")[0];
              Severity: Major
              Found in lib/routes/renders.js - About 2 hrs to fix

                Consider simplifying this complex logical expression.
                Open

                  if (is_session_req && req_count() >= config.server.sessions_rate_limit) {
                    var e = new Error("Skipped, rate limit exceeded");
                    e.name = "HTTP";
                    e.code = "RATELIMIT";
                
                
                Severity: Critical
                Found in lib/networking.js - About 2 hrs to fix

                  Function store_skin has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function store_skin(rid, userId, profile, cache_details, callback) {
                    networking.get_skin_info(rid, userId, profile, function(err, url, slim) {
                      if (err) {
                        slim = cache_details ? cache_details.slim : undefined;
                      }
                  Severity: Major
                  Found in lib/helpers.js - About 2 hrs to fix

                    Function exports has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    module.exports = function(req, callback) {
                      var userId = (req.url.path_list[1] || "").split(".")[0];
                      var size = parseInt(req.url.searchParams.get("size")) || config.avatars.default_size;
                      var def = req.url.searchParams.get("default");
                      var overlay = req.url.searchParams.has("overlay") || req.url.searchParams.has("helm");
                    Severity: Minor
                    Found in lib/routes/avatars.js - About 1 hr to fix

                      Function handle_default has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function handle_default(img_status, userId, def, req, err, callback) {
                        def = def || skins.default_skin(userId);
                        var defname = def.toLowerCase();
                        if (defname !== "steve" && defname !== "mhf_steve" && defname !== "alex" && defname !== "mhf_alex") {
                          if (helpers.id_valid(def)) {
                      Severity: Minor
                      Found in lib/routes/skins.js - About 1 hr to fix

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

                        module.exports = function(req, callback) {
                          var userId = (req.url.path_list[1] || "").split(".")[0];
                          var def = req.url.searchParams.get("default");
                          var rid = req.id;
                        
                        
                        Severity: Minor
                        Found in lib/routes/skins.js - About 1 hr to fix

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

                          module.exports = function(req, callback) {
                            var userId = (req.url.path_list[1] || "").split(".")[0];
                            var def = req.url.searchParams.get('default');
                            var rid = req.id;
                          
                          
                          Severity: Minor
                          Found in lib/routes/capes.js - About 1 hr to fix

                            Function handle_default has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function handle_default(rid, scale, overlay, body, img_status, userId, size, def, req, err, callback) {
                              def = def || skins.default_skin(userId);
                              var defname = def.toLowerCase();
                              if (defname !== "steve" && defname !== "mhf_steve" && defname !== "alex" && defname !== "mhf_alex") {
                                if (helpers.id_valid(def)) {
                            Severity: Minor
                            Found in lib/routes/renders.js - About 1 hr to fix

                              Function store_images has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function store_images(rid, userId, cache_details, type, callback) {
                                if (requests[type]["!" + userId]) {
                                  logging.debug(rid, "adding to request queue");
                                  push_request(userId, type, callback);
                                } else {
                              Severity: Minor
                              Found in lib/helpers.js - About 1 hr to fix

                                Function requestHandler has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                                Open

                                function requestHandler(req, res) {
                                  req.url = new URL(decodeURI(req.url), 'http://' + req.headers.host);
                                  req.url.pathname = path.resolve('/', req.url.pathname);
                                  req.url.path_list = path_list(req.url.pathname);
                                  req.id = request_id();
                                Severity: Minor
                                Found in lib/server.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 handle_default has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function handle_default(img_status, userId, size, def, req, err, callback) {
                                  def = def || skins.default_skin(userId);
                                  var defname = def.toLowerCase();
                                  if (defname !== "steve" && defname !== "mhf_steve" && defname !== "alex" && defname !== "mhf_alex") {
                                    if (helpers.id_valid(def)) {
                                Severity: Minor
                                Found in lib/routes/avatars.js - About 1 hr to fix

                                  Function handle_default has 11 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                  function handle_default(rid, scale, overlay, body, img_status, userId, size, def, req, err, callback) {
                                  Severity: Major
                                  Found in lib/routes/renders.js - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language