phpffcms/ffcms-core

View on GitHub

Showing 54 of 54 total issues

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

    Method validate has 28 lines of code (exceeds 25 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

      Method saveFromUrl has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function saveFromUrl($url, $path)
          {
              if (!filter_var($url, FILTER_VALIDATE_URL) || !function_exists('curl_init')) {
                  return false;
              }
      Severity: Minor
      Found in src/Helper/FileSystem/File.php - About 1 hr to fix

        Function makeUp has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function makeUp($file)
            {
                // check if argument is array of files and run recursion
                if (Any::isArray($file)) {
                    $success = true;
        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 get has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function get(?string $index, string $text, ?array $params = null)
            {
                if (App::$Request->getLanguage() !== App::$Properties->get('baseLanguage')) {
                    if ($index && !Arr::in($index, $this->indexes)) {
                        $this->cached = Arr::merge($this->cached, $this->load($index));
        Severity: Minor
        Found in src/I18n/Translate.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 makeUp has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function makeUp($file)
            {
                // check if argument is array of files and run recursion
                if (Any::isArray($file)) {
                    $success = true;
        Severity: Minor
        Found in src/Managers/MigrationsManager.php - About 1 hr to fix

          Method get has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function get(string $configKey, string $configFile = 'default', ?string $parseType = null)
              {
                  $this->load($configFile);
                  // check if configs for this file is loaded
                  if (!isset($this->data[$configFile])) {
          Severity: Minor
          Found in src/Properties.php - About 1 hr to fix

            Function setLanguageFromBrowser has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                private function setLanguageFromBrowser(): void
                {
                    $userLang = App::$Properties->get('singleLanguage');
                    $browserAccept = $this->getLanguages();
                    if (Any::isArray($browserAccept) && count($browserAccept) > 0) {
            Severity: Minor
            Found in src/Network/Request/MultiLanguageFeatures.php - About 55 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 run has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function run()
                {
                    // check if cron instances is defined
                    if (!isset($this->configs['instances']) || !Any::isArray($this->configs['instances'])) {
                        return null;
            Severity: Minor
            Found in src/Managers/CronManager.php - About 55 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 makeDown has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function makeDown($file)
                {
                    if (Any::isArray($file)) {
                        $success = true;
                        foreach ($file as $item) {
            Severity: Minor
            Found in src/Managers/MigrationsManager.php - About 55 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

            Method __construct has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function __construct(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
            Severity: Major
            Found in src/Network/Request.php - About 50 mins to fix

              Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function initialize(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
              Severity: Major
              Found in src/Network/Request.php - About 50 mins to fix

                Function widget has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function widget(?array $params = null): ?string
                    {
                        self::$class = get_called_class();
                        self::$view = App::$View;
                        self::$request = App::$Request;
                Severity: Minor
                Found in src/Arch/Widget.php - About 45 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 recursiveChmod has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function recursiveChmod($path, $mod = 0777)
                    {
                        $path = Normalize::diskFullPath($path);
                        if (!self::exist($path)) {
                            return;
                Severity: Minor
                Found in src/Helper/FileSystem/Directory.php - About 45 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 snippet has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function snippet(string $text, int $length = 200)
                    {
                        $breakerPos = mb_strpos($text, self::WYSIWYG_BREAK_HTML, null, 'UTF-8');
                        // offset is founded, try to split preview from full text
                        if ($breakerPos !== false) {
                Severity: Minor
                Found in src/Helper/Text.php - About 45 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 isFile has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function isFile($object, $value): bool
                    {
                        // allow empty fields, "required" option filter that
                        if ($object === null) {
                            return true;
                Severity: Minor
                Found in src/Helper/ModelFilters.php - About 45 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 humanize has a Cognitive Complexity of 8 (exceeds 5 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 45 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 __construct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function __construct()
                    {
                        // make alias for view pathway
                        $this->currentViewPath = App::$View->getCurrentPath();
                
                
                Severity: Minor
                Found in src/Alias.php - About 35 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 exportVar has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function exportVar($var, $indent = null, $guessTypes = false)
                    {
                        switch (gettype($var)) {
                            case 'string':
                                // guess boolean type for "1" and "0"
                Severity: Minor
                Found in src/Helper/Type/Arr.php - About 35 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 get has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function get(string $configKey, string $configFile = 'default', ?string $parseType = null)
                    {
                        $this->load($configFile);
                        // check if configs for this file is loaded
                        if (!isset($this->data[$configFile])) {
                Severity: Minor
                Found in src/Properties.php - About 35 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

                Severity
                Category
                Status
                Source
                Language