concord-consortium/rigse

View on GitHub
external-report-demo/report-demo/app.js

Summary

Maintainability
C
1 day
Test Coverage

Function lambdaHandler has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

exports.lambdaHandler = async (event, context) => {
    try {
      const body = validateJSON(event);

      if (body.jwt) {
Severity: Major
Found in external-report-demo/report-demo/app.js - About 2 hrs to fix

    Function lambdaHandler has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.lambdaHandler = async (event, context) => {
        try {
          const body = validateJSON(event);
    
          if (body.jwt) {
    Severity: Minor
    Found in external-report-demo/report-demo/app.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 getLearnerDataWithJwt has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    async function getLearnerDataWithJwt(learnersApiUrl, queryParams, jwt) {
      try {
        const res = await axios.post(learnersApiUrl, queryParams,
          {
            headers: {
    Severity: Minor
    Found in external-report-demo/report-demo/app.js - About 1 hr to fix

      Function validateJSON has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function validateJSON(event) {
        if (!event.body) {
          throw new Error("Missing post body in request")
        }
      
      
      Severity: Minor
      Found in external-report-demo/report-demo/app.js - About 1 hr to fix

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

        async function fetchLearnerData(jwt, query, learnersApiUrl, pageSize) {
          const queryParams = {
            query,
            page_size: pageSize
          };
        Severity: Minor
        Found in external-report-demo/report-demo/app.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 validateJSON has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        function validateJSON(event) {
          if (!event.body) {
            throw new Error("Missing post body in request")
          }
        
        
        Severity: Minor
        Found in external-report-demo/report-demo/app.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

        There are no issues that match your filters.

        Category
        Status