phpffcms/ffcms-core

View on GitHub

Showing 54 of 54 total issues

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

ModelFilters has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

class ModelFilters
{

    /**
     * Filter ['object', 'length_min', 'length']
Severity: Minor
Found in src/Helper/ModelFilters.php - About 2 hrs to fix

    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

    Str has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Str
    {
        /**
         * Check if string is empty (check null, false and '' values)
         * @param string|null $string
    Severity: Minor
    Found in src/Helper/Type/Str.php - About 2 hrs to fix

      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 listFiles has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function listFiles($path, array $ext = null, $returnRelative = false, &$files = [])
            {
                $path = Normalize::diskFullPath($path);
        
                if (!Directory::exist($path)) {
        Severity: Minor
        Found in src/Helper/FileSystem/File.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

        Function compileBootableClasses has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

            public function compileBootableClasses(): void
            {
                // list app root's
                foreach ($this->appRoots as $app) {
                    $app .= '/Apps/Controller/' . env_name;
        Severity: Minor
        Found in src/Managers/BootManager.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

        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

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

            final public function getValidationRule($field): array
            {
                $rules = $this->rules();
                $response = [];
        
        
        Severity: Minor
        Found in src/Arch/Model.php - 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 loadAverage has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function loadAverage()
            {
                $load = 0;
                if (stristr(PHP_OS, 'win')) {
                    // its not a better solution, but no other way to do this
        Severity: Minor
        Found in src/Helper/Environment.php - 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 search has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public function search(?string $query = null, bool $exist = false)
            {
                // initialize db migration record
                $records = new Migration();
                if ($this->connection !== null) {
        Severity: Minor
        Found in src/Managers/MigrationsManager.php - 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 parseComposerLoader has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            private function parseComposerLoader(): void
            {
                // get composer autoload map
                $map = $this->loader->getPrefixes();
                if (Any::isArray($map)) {
        Severity: Minor
        Found in src/Managers/BootManager.php - 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 validate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            final public function validate(): bool
            {
                // validate csrf token if required
                if ($this->_tokenRequired && !$this->_tokenOk) {
                    App::$Session->getFlashBag()->add('warning', __('Hack attention: security token is wrong!'));
        Severity: Minor
        Found in src/Arch/Model.php - 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

        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

          Function diskPath has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function diskPath($path)
              {
                  // its full-based path? Lets return real path
                  if (Str::startsWith(root, $path)) {
                      // fix path collisions if is not exist
          Severity: Minor
          Found in src/Helper/FileSystem/Normalize.php - 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

          Method run has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function run(): void
              {
                  try {
                      /** @var \Ffcms\Core\Arch\Controller $callClass */
                      $callClass = $this->getCallbackClass();
          Severity: Minor
          Found in src/App.php - About 1 hr to fix

            Function run has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                public function run(): void
                {
                    try {
                        /** @var \Ffcms\Core\Arch\Controller $callClass */
                        $callClass = $this->getCallbackClass();
            Severity: Minor
            Found in src/App.php - 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 runMultiLanguage has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                private function runMultiLanguage(): void
                {
                    // check if multi-language is enabled
                    if (!App::$Properties->get('multiLanguage')) {
                        $this->language = App::$Properties->get('singleLanguage');
            Severity: Minor
            Found in src/Network/Request/MultiLanguageFeatures.php - 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 loadDynamicServices has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                private function loadDynamicServices(): void
                {
                    $this->startMeasure(__METHOD__);
            
                    /** @var array $objects */
            Severity: Minor
            Found in src/App.php - 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

            Method humanize has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function humanize($raw)
                {
                    // convert to timestamp
                    $timestamp = $raw;
                    // raw can be instance of eloquent active record object, convert to str
            Severity: Minor
            Found in src/Helper/Date.php - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language