phpmyadmin/phpmyadmin

View on GitHub
resources/js/src/error_report.ts

Summary

Maintainability
B
6 hrs
Test Coverage

Function getReportData has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    getReportData: function (exception) {
        if (exception && exception.stack && exception.stack.length) {
            for (var i = 0; i < exception.stack.length; i++) {
                var stack = exception.stack[i];
                if (stack.context && stack.context.length) {
Severity: Minor
Found in resources/js/src/error_report.ts - 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 showReportDialog has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    showReportDialog: function (exception): void {
        const reportData = ErrorReport.getReportData(exception);

        const sendErrorReport = function () {
            const postData = $.extend(reportData, {
Severity: Minor
Found in resources/js/src/error_report.ts - About 1 hr to fix

    Function getReportData has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        getReportData: function (exception) {
            if (exception && exception.stack && exception.stack.length) {
                for (var i = 0; i < exception.stack.length; i++) {
                    var stack = exception.stack[i];
                    if (stack.context && stack.context.length) {
    Severity: Minor
    Found in resources/js/src/error_report.ts - About 1 hr to fix

      Function showErrorNotification has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          showErrorNotification: function (): void {
              var key = Math.random().toString(36).substring(2, 12);
              while (key in ErrorReport.keyDict) {
                  key = Math.random().toString(36).substring(2, 12);
              }
      Severity: Minor
      Found in resources/js/src/error_report.ts - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                                if (stack.context[j].length > 80) {
                                    stack.context[j] = stack.context[j].substring(-1, 75) + '//...';
                                }
        Severity: Major
        Found in resources/js/src/error_report.ts - About 45 mins to fix

          Function wrapFunction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              wrapFunction: function (func) {
                  if (! func.wrapped) {
                      var newFunc = function () {
                          try {
                              return func.apply(this, arguments);
          Severity: Minor
          Found in resources/js/src/error_report.ts - 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

          There are no issues that match your filters.

          Category
          Status