bnomei/kirby3-srcset

View on GitHub
classes/Bnomei/Srcset.php

Summary

Maintainability
C
1 day
Test Coverage

Function dataFromTag has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function dataFromTag(KirbyTag $tag)
    {
        $data = [];
        foreach ($this->attrKeys() as $attr) {
            $val = $tag->$attr;
Severity: Minor
Found in classes/Bnomei/Srcset.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 normalizeData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function normalizeData(array $data)
    {
        $norm = [];
        foreach ($data as $key => $val) {
            if (is_string($val) && $val === 'true') {
Severity: Minor
Found in classes/Bnomei/Srcset.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 applySrcset has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function applySrcset(string $text, array $data = []): string
    {
        $srcfile = new SrcsetFile(
            A::get($data, 'file'),
            A::get($data, 'sizes'),
Severity: Minor
Found in classes/Bnomei/Srcset.php - About 1 hr to fix

    Method applyRatio has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Wontfix

        public function applyRatio(string $text, array $data = []): string
        {
            if (!A::get($data, 'figure') || !A::get($data, 'ratio')) {
                return $text;
            }
    Severity: Minor
    Found in classes/Bnomei/Srcset.php - About 1 hr to fix

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

          public function dataFromTag(KirbyTag $tag)
          {
              $data = [];
              foreach ($this->attrKeys() as $attr) {
                  $val = $tag->$attr;
      Severity: Minor
      Found in classes/Bnomei/Srcset.php - About 1 hr to fix

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

            public function imageKirbytagFromData(array $data = []): string
            {
                $attrs = ['(image: ' . self::PLACEHOLDER]; // A::get($data, 'value')
                $lazy = A::get($data, 'lazy');
                if ($lazy) {
        Severity: Minor
        Found in classes/Bnomei/Srcset.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 applySrcset has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function applySrcset(string $text, array $data = []): string
            {
                $srcfile = new SrcsetFile(
                    A::get($data, 'file'),
                    A::get($data, 'sizes'),
        Severity: Minor
        Found in classes/Bnomei/Srcset.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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __construct($data = null, array $options = [])
            {
                if (is_a($data, 'Kirby\Cms\KirbyTag')) {
                    $this->parent = $data->parent();
                    $options = $this->dataFromTag($data);
        Severity: Minor
        Found in classes/Bnomei/Srcset.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