liuxiaodong/weixin-service

View on GitHub

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');
Severity: Minor
Found in lib/wxService.js - About 4 hrs to fix

    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');
    
    
    Severity: Major
    Found in lib/wxService.js - About 2 hrs to fix

      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;
      Severity: Minor
      Found in lib/util.js - About 2 hrs 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 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');
      
      
      Severity: Minor
      Found in lib/wxService.js - About 1 hr 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 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);
        }
      
      
      Severity: Minor
      Found in lib/wxService.js - About 1 hr 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 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') {
      Severity: Minor
      Found in lib/request.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 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);
      Severity: Minor
      Found in lib/wxService.js - About 25 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

      Severity
      Category
      Status
      Source
      Language