maskletter/tenp

View on GitHub
core/dist/lib/plugin/validator.plugin.js

Summary

Maintainability
C
1 day
Test Coverage

Function ValidatorPlugin has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

var ValidatorPlugin = /** @class */ (function () {
    function ValidatorPlugin() {
        this.defaultType = {
            phone: /^1[34578]\d{9}$/,
            email: /^[a-z0-9]+([._\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
Severity: Minor
Found in core/dist/lib/plugin/validator.plugin.js - About 6 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 ValidatorPlugin has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var ValidatorPlugin = /** @class */ (function () {
    function ValidatorPlugin() {
        this.defaultType = {
            phone: /^1[34578]\d{9}$/,
            email: /^[a-z0-9]+([._\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
Severity: Major
Found in core/dist/lib/plugin/validator.plugin.js - About 2 hrs to fix

    Function validator has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        ValidatorPlugin.prototype.validator = function (data, validator, request, response) {
            var done = validator.done ? validator.done : this.globalDone ? this.globalDone : this.defaultDone;
            var result = false;
            for (var name_1 in validator) {
                if (name_1 == 'done')
    Severity: Minor
    Found in core/dist/lib/plugin/validator.plugin.js - About 1 hr to fix

      There are no issues that match your filters.

      Category
      Status