reharik/papers

View on GitHub

Showing 8 of 8 total issues

Function exports has 117 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function() {

  logIn = function (req, user, papers) {
    req[papers.options.userProperty] = user;
    if(!papers.options.useSession || !req.session){
Severity: Major
Found in src/papers.js - About 4 hrs to fix

    Function iterateStrategies has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        co(function *iterateStrategies() {
    
          const checkSession = yield checkSessionForAuth(papers, req);
          if(checkSession.isLoggedIn) {
            return {type:'session'};
    Severity: Minor
    Found in src/authenticationMiddleware.js - About 1 hr to fix

      Function registerMiddleware has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          registerMiddleware: function (config) {
            if (!config || !config.strategies || config.strategies.length <= 0) {
              throw new Error('You must provide at lease one strategy.');
            }
            if(config.useSession && (
      Severity: Minor
      Found in src/papers.js - About 1 hr to fix

        Function exports has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = (failures, res, papers) => {
          if (failures.length <= 0) {
            failures.push({errorMessage: "No successful login strategy found", statusCode: 401})
          }
        
        
        Severity: Minor
        Found in src/handleFailurePostIteration.js - About 1 hr to fix

          Function exports has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = (failures, res, papers) => {
            if (failures.length <= 0) {
              failures.push({errorMessage: "No successful login strategy found", statusCode: 401})
            }
          
          
          Severity: Minor
          Found in src/handleFailurePostIteration.js - About 55 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 exports has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports = function() {
          
            logIn = function (req, user, papers) {
              req[papers.options.userProperty] = user;
              if(!papers.options.useSession || !req.session){
          Severity: Minor
          Found in src/papers.js - About 35 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

          Avoid too many return statements within this function.
          Open

                return handleFailurePostIteration(failures, res, papers);
          Severity: Major
          Found in src/authenticationMiddleware.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                      return res.end(http.STATUS_CODES[res.statusCode]);
            Severity: Major
            Found in src/authenticationMiddleware.js - About 30 mins to fix
              Severity
              Category
              Status
              Source
              Language