lib/helpers.js
File helpers.js
has 323 lines of code (exceeds 250 allowed). Consider refactoring. Open
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
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 store_skin
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
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 store_images
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
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 get_image_hash
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
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;
Function store_cape
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
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) {
Function get_render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
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;
Function get_render
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
exp.get_render = function(rid, userId, scale, overlay, body, callback) {
Avoid deeply nested control flow statements. Open
Open
if (skin_err) {
callback(skin_err, null, slim);
} else {
skins.extract_face(img, facepath, function(err2) {
if (err2) {
Function store_skin
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function store_skin(rid, userId, profile, cache_details, callback) {
Function get_avatar
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
exp.get_avatar = function(rid, userId, overlay, size, callback) {
Function store_images
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function store_images(rid, userId, cache_details, type, callback) {
Function resume
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function resume(userId, type, err, hash, slim) {
Function store_cape
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function store_cape(rid, userId, profile, cache_details, callback) {