resources/js/src/error_report.ts
Function getReportData
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
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) {
- Read upRead up
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
Open
showReportDialog: function (exception): void {
const reportData = ErrorReport.getReportData(exception);
const sendErrorReport = function () {
const postData = $.extend(reportData, {
Function getReportData
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
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) {
Function showErrorNotification
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
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);
}
Avoid deeply nested control flow statements. Open
Open
if (stack.context[j].length > 80) {
stack.context[j] = stack.context[j].substring(-1, 75) + '//...';
}
Function wrapFunction
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
wrapFunction: function (func) {
if (! func.wrapped) {
var newFunc = function () {
try {
return func.apply(this, arguments);
- Read upRead up
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"