crafatar/crafatar

View on GitHub
lib/skins.js

Summary

Maintainability
C
7 hrs
Test Coverage

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

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

        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

          There are no issues that match your filters.

          Category
          Status