crafatar/crafatar

View on GitHub

Showing 49 of 62 total issues

Function get_image_hash has 34 lines of code (exceeds 25 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 1 hr to fix

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

    function store_cape(rid, userId, profile, cache_details, callback) {
      networking.get_cape_url(rid, userId, profile, function(err, url) {
        if (!err && url) {
          var cape_hash = get_hash(url);
          if (cache_details && cache_details.cape === cape_hash) {
    Severity: Minor
    Found in lib/helpers.js - About 1 hr to fix

      Function get_render has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      exp.get_render = function(rid, userId, scale, overlay, body, callback) {
        exp.get_skin(rid, userId, function(err, skin_hash, status, img, slim) {
          if (!skin_hash) {
            callback(err, status, skin_hash, null);
            return;
      Severity: Minor
      Found in lib/helpers.js - About 1 hr to fix

        Function asset_request has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function asset_request(req, callback) {
          const filename = path.join(__dirname, "public", ...req.url.path_list);
          const relative = path.relative(path.join(__dirname, "public"), filename);
          if (relative && !relative.startsWith('..') && !path.isAbsolute(relative)) {
            fs.access(filename, function(fs_err) {
        Severity: Minor
        Found in lib/server.js - About 1 hr to fix

          Function handle_default has a Cognitive Complexity of 9 (exceeds 5 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 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 handle_default has a Cognitive Complexity of 9 (exceeds 5 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 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 handle_default has a Cognitive Complexity of 9 (exceeds 5 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 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 draw_model has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          exp.draw_model = function(rid, img, scale, overlay, is_body, slim, callback) {
          Severity: Major
          Found in lib/renders.js - About 50 mins to fix

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

            function handle_default(img_status, userId, size, def, req, err, callback) {
            Severity: Major
            Found in lib/routes/avatars.js - About 50 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if (crop_err) {
                                    callback(crop_err);
                                  } else {
                                    face_img.paste(0, 0, helm_img, function(img_err, face_helm_img) {
                                      if (img_err) {
              Severity: Major
              Found in lib/skins.js - About 45 mins to fix

                Function getPart has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function getPart(src, x, y, width, height, scale) {
                Severity: Minor
                Found in lib/renders.js - About 45 mins to fix

                  Function extract_helm has a Cognitive Complexity of 8 (exceeds 5 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: Minor
                  Found in lib/skins.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

                  Avoid deeply nested control flow statements.
                  Open

                                    if (skin_err) {
                                      callback(skin_err, null, slim);
                                    } else {
                                      skins.extract_face(img, facepath, function(err2) {
                                        if (err2) {
                  Severity: Major
                  Found in lib/helpers.js - About 45 mins to fix

                    Function resize_img has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    exp.resize_img = function(inname, size, callback) {
                      lwip.open(inname, function(err, image) {
                        if (err) {
                          callback(err, null);
                        } else {
                    Severity: Minor
                    Found in lib/skins.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 get_render has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    exp.get_render = function(rid, userId, scale, overlay, body, callback) {
                    Severity: Minor
                    Found in lib/helpers.js - About 45 mins to fix

                      Function save_hash has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      exp.save_hash = function(rid, userId, skin_hash, cape_hash, slim, callback) {
                      Severity: Minor
                      Found in lib/cache.js - About 45 mins to fix

                        Function exports has a Cognitive Complexity of 8 (exceeds 5 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: Minor
                        Found in lib/routes/renders.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 extract_face has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                        exp.extract_face = function(buffer, outname, callback) {
                          lwip.open(buffer, "png", function(err, image) {
                            if (err) {
                              callback(err);
                            } else {
                        Severity: Minor
                        Found in lib/skins.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 handle_default has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        function handle_default(img_status, userId, def, req, err, callback) {
                        Severity: Minor
                        Found in lib/routes/skins.js - About 45 mins to fix

                          Function save_image has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                          exp.save_image = function(buffer, outpath, callback) {
                            lwip.open(buffer, "png", function(err, image) {
                              if (err) {
                                callback(err);
                              } else {
                          Severity: Minor
                          Found in lib/skins.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

                          Severity
                          Category
                          Status
                          Source
                          Language