jaredhanson/connect-lrdd

View on GitHub

Showing 5 of 11 total issues

Function lrdd has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function lrdd(fn, options) {
  options = options || {};
  var param = options.param || 'uri';
  
  return function lrdd(req, res, next) {
Severity: Minor
Found in lib/middleware/lrdd.js - About 3 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 serializeToJRD has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function serializeToJRD(descriptor) {
  var obj = {};
  if (descriptor.expires) { obj.expires = xsdDateTimeString(descriptor.expires); }
  if (descriptor.subject) { obj.subject = descriptor.subject; }
  if (descriptor.aliases.length > 0) {
Severity: Minor
Found in lib/middleware/lrdd.js - About 1 hr to fix

    Function serializeToXRD has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function serializeToXRD(descriptor) {
      var xml = '<?xml version="1.0" encoding="UTF-8"?>';
      xml += '<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">';
    
      if (descriptor.expires) {
    Severity: Minor
    Found in lib/middleware/lrdd.js - About 1 hr to fix

      Function lrdd has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function lrdd(fn, options) {
        options = options || {};
        var param = options.param || 'uri';
        
        return function lrdd(req, res, next) {
      Severity: Minor
      Found in lib/middleware/lrdd.js - About 1 hr to fix

        Function lrdd has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          return function lrdd(req, res, next) {
            var uri;
            if (req.params && req.params[param]) {
              uri = req.params[param];
            } if (req.query && req.query[param]) {
        Severity: Minor
        Found in lib/middleware/lrdd.js - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language