crafatar/crafatar

View on GitHub

Showing 62 of 62 total issues

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 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 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 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

        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

        Avoid deeply nested control flow statements.
        Open

                          if (skin_img.__trans) { // eslint-disable-line no-underscore-dangle
                            xloop:
                            for (var x = 0; x < helm_area.width(); x++) {
                              for (var y = 0; y < helm_area.height(); y++) {
                                // check if transparency-bounding-box has transparency
        Severity: Major
        Found in lib/skins.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 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 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

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

                    renders.draw_model(rid, buf, scale, overlay, body, def === "mhf_alex", function(render_err, def_img) {
                      callback({
                        status: img_status,
                        body: def_img,
                        type: "image/png",
              Severity: Minor
              Found in lib/routes/renders.js and 1 other location - About 40 mins to fix
              lib/routes/skins.js on lines 41..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 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

                      image.toBuffer("png", function(buf_err, buffer) {
                        callback({
                          status: img_status,
                          body: buffer,
                          type: "image/png",
              Severity: Minor
              Found in lib/routes/skins.js and 1 other location - About 40 mins to fix
              lib/routes/renders.js on lines 44..52

              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

              Consider simplifying this complex logical expression.
              Open

                if (defname !== "steve" && defname !== "mhf_steve" && defname !== "alex" && defname !== "mhf_alex") {
                  if (helpers.id_valid(def)) {
                    // clean up the old URL to match new image
                    req.url.searchParams.delete('default');
                    req.url.path_list[2] = def;
              Severity: Major
              Found in lib/routes/renders.js - About 40 mins to fix

                Function store_skin has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                function store_skin(rid, userId, profile, cache_details, callback) {
                Severity: Minor
                Found in lib/helpers.js - About 35 mins to fix

                  Function extract_helm has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  exp.extract_helm = function(rid, facefile, buffer, outname, callback) {
                  Severity: Minor
                  Found in lib/skins.js - About 35 mins to fix

                    Function get_avatar has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    exp.get_avatar = function(rid, userId, overlay, size, callback) {
                    Severity: Minor
                    Found in lib/helpers.js - About 35 mins to fix

                      Function store_images has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      function store_images(rid, userId, cache_details, type, callback) {
                      Severity: Minor
                      Found in lib/helpers.js - About 35 mins to fix

                        Function resume has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        function resume(userId, type, err, hash, slim) {
                        Severity: Minor
                        Found in lib/helpers.js - About 35 mins to fix

                          Function store_cape has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          function store_cape(rid, userId, profile, cache_details, callback) {
                          Severity: Minor
                          Found in lib/helpers.js - About 35 mins to fix

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

                              var overlay = req.url.searchParams.has("overlay") || req.url.searchParams.has("helm");
                            Severity: Minor
                            Found in lib/routes/renders.js and 1 other location - About 30 mins to fix
                            lib/routes/avatars.js on lines 56..56

                            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 45.

                            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