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,
- Read upRead up
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);
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");
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;
- Read upRead up
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 {
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,
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();
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) {
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];
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";
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;
}
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");
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)) {
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;
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;
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)) {
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 {
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();
- Read upRead up
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)) {
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) {