luyadev/luya-module-cms

View on GitHub
src/helpers/BlockHelper.php

Summary

Maintainability
B
5 hrs
Test Coverage
D
64%

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

    public static function fileArrayUpload(array|string|null|int $value, $returnObject = false)
    {
        if (!empty($value) && is_array($value)) {
            $data = [];
            foreach ($value as $key => $item) {
Severity: Minor
Found in src/helpers/BlockHelper.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 imageArrayUpload has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public static function imageArrayUpload(string|int|null|array $value, bool|string $applyFilter = false, $returnObject = false)
    {
        if (!empty($value) && is_array($value)) {
            $data = [];

Severity: Minor
Found in src/helpers/BlockHelper.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 imageUpload has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public static function imageUpload(string|int|null $value, bool|string $applyFilter = false, $returnObject = false): bool|array|\luya\admin\image\Item
    {
        if (empty($value)) {
            return false;
        }
Severity: Minor
Found in src/helpers/BlockHelper.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

Avoid too many return statements within this method.
Open

        return $image->toArray();
Severity: Major
Found in src/helpers/BlockHelper.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                return $image;
    Severity: Major
    Found in src/helpers/BlockHelper.php - About 30 mins to fix

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

          public static function fileUpload($fileId, $returnObject = false): bool|array|\luya\admin\file\Item
          {
              if (!empty($fileId)) {
                  $file = Yii::$app->storage->getFile($fileId);
                  /* @var \luya\admin\file\Item $file */
      Severity: Minor
      Found in src/helpers/BlockHelper.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