phpffcms/ffcms-core

View on GitHub
src/Traits/ModelValidator.php

Summary

Maintainability
D
2 days
Test Coverage

Function validateRecursive has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    public function validateRecursive($propertyName, $filterName, $filterArgs = null)
    {
        // check if we got it from form defined request method
        if (App::$Request->getMethod() !== $this->_sendMethod) {
            return false;
Severity: Minor
Found in src/Traits/ModelValidator.php - About 5 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 runValidate has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function runValidate(array $rules = null)
    {
        // skip validation on empty rules
        if ($rules === null) {
            return true;
Severity: Minor
Found in src/Traits/ModelValidator.php - 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

Method validateRecursive has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function validateRecursive($propertyName, $filterName, $filterArgs = null)
    {
        // check if we got it from form defined request method
        if (App::$Request->getMethod() !== $this->_sendMethod) {
            return false;
Severity: Major
Found in src/Traits/ModelValidator.php - About 2 hrs to fix

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

        public function getRequest($param, $method = null)
        {
            if ($method === null) {
                $method = $this->_sendMethod;
            }
    Severity: Minor
    Found in src/Traits/ModelValidator.php - 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

    Method getRequest has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getRequest($param, $method = null)
        {
            if ($method === null) {
                $method = $this->_sendMethod;
            }
    Severity: Minor
    Found in src/Traits/ModelValidator.php - About 1 hr to fix

      Method runValidate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function runValidate(array $rules = null)
          {
              // skip validation on empty rules
              if ($rules === null) {
                  return true;
      Severity: Minor
      Found in src/Traits/ModelValidator.php - About 1 hr to fix

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

            public function initialize($csrf = false)
            {
                $this->_tokenRequired = $csrf;
                if ($csrf) {
                    // get current token value from session
        Severity: Minor
        Found in src/Traits/ModelValidator.php - 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

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

            private function getFieldValue($propertyName)
            {
                // get type of input data (where we must look it up)
                $inputType = Str::lowerCase($this->_sendMethod);
                $filterType = 'text';
        Severity: Minor
        Found in src/Traits/ModelValidator.php - 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