meyfa/php-svg

View on GitHub

Showing 27 of 54 total issues

Function prepareRenderParams has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function prepareRenderParams(array $options, Transform $transform, ?FontRegistry $fontRegistry): ?array
    {
        // this assumes there is no rotation or skew, but that's fine, we can't deal with that anyway
        $size1 = $options['fontSize'];
        $size2 = $size1;
Severity: Minor
Found in src/Rasterization/Renderers/TextRenderer.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 approximate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function approximate(array $commands): void
    {
        // https://www.w3.org/TR/SVG/paths.html#PathDataMovetoCommands
        // "A path data segment (if there is one) must begin with a "moveto" command."
        if (empty($commands) || ($commands[0]['id'] !== 'M' && $commands[0]['id'] !== 'm')) {
Severity: Minor
Found in src/Rasterization/Path/PathApproximator.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

Avoid too many return statements within this method.
Open

        return true;
Severity: Major
Found in src/Rasterization/Path/PathParser.php - About 30 mins to fix

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

        protected function prepareRenderParams(array $options, Transform $transform, ?FontRegistry $fontRegistry): ?array
        {
            $w = $options['width'];
            $h = $options['height'];
            $transform->resize($w, $h);
    Severity: Minor
    Found in src/Rasterization/Renderers/RectRenderer.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 parseCss has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function parseCss(string $css): array
        {
            $result = [];
            preg_match_all('/(?ims)([a-z0-9\s\,\.\:#_\-@^*()\[\]\"\'=]+)\{([^\}]*)\}/', $css, $arr);
    
    
    Severity: Minor
    Found in src/Utilities/SVGStyleParser.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 joinPoints has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        private static function joinPoints(array $pointsArray): string
        {
            $pointsString = '';
            foreach ($pointsArray as $point) {
                if (count($point) < 2) {
    Severity: Minor
    Found in src/Nodes/Shapes/SVGPolygonalShape.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 writeNode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public function writeNode(SVGNode $node): void
        {
            $this->outString .= '<' . $node->getName();
    
            $this->appendNamespaces($node->getSerializableNamespaces());
    Severity: Minor
    Found in src/Writing/SVGWriter.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

    Severity
    Category
    Status
    Source
    Language