Showing 7 of 13 total issues
File wxService.js
has 337 lines of code (exceeds 250 allowed). Consider refactoring. Open
var debug = require('debug')('weixin-server');
var crypto = require('crypto');
var getRawBody = require('raw-body');
var parseString = require('xml2js').parseString;
var WXBizMsgCrypt = require('wechat-crypto');
Function reply
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
function reply(req, self) {
var wechatidAttr = self.attrNameProcessors('ToUserName'),
openidAttr =self. attrNameProcessors('FromUserName'),
encryptAttr = self.attrNameProcessors('Encrypt');
Function attrFormat
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
exports.attrFormat = function(data, attrNameProcessors){
var _format = function(data){
for(var p in data){
var value = data[p];
var prot = p;
- 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 reply
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function reply(req, self) {
var wechatidAttr = self.attrNameProcessors('ToUserName'),
openidAttr =self. attrNameProcessors('FromUserName'),
encryptAttr = self.attrNameProcessors('Encrypt');
- 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 WxService
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
var WxService = function(options){
if(!(this instanceof WxService)) {
return new WxService(options);
}
- 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 mergeOpts
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
var mergeOpts = function (src, target){
var options = {};
extend(options, src);
for (var key in target) {
if (key !== 'headers') {
- 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 getToken
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
WxService.prototype.getToken = function(callback){
callback = is(callback, 'function') ? callback : function(){};
if(this.tokenStore){
if((new Date().getTime()) < this.tokenStore.expireTime) {
callback(null, this.tokenStore);
- 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"