bkdotcom/PHPDebugConsole

View on GitHub
dev/UpdateCharData.php

Summary

Maintainability
A
0 mins
Test Coverage

Define a constant instead of duplicating this literal "charBCodePoint" 4 times.
Open

        $parts = \array_combine(['charACodePoint', 'charBCodePoint', 'comment'], $parts);
Severity: Critical
Found in dev/UpdateCharData.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "charA" 7 times.
Open

            $isCharAAscii = \strlen($row['charA']) === 1 && \ord($row['charA']) < 0x80;
Severity: Critical
Found in dev/UpdateCharData.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "charACodePoint" 7 times.
Open

                'codePoint' => $row['charACodePoint'],
Severity: Critical
Found in dev/UpdateCharData.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "charB" 4 times.
Open

            $isCharBAscii = \strlen($row['charB']) === 1 && \ord($row['charB']) < 0x80;
Severity: Critical
Found in dev/UpdateCharData.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "charADesc" 3 times.
Open

                'desc' => $row['charADesc'],
Severity: Critical
Found in dev/UpdateCharData.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Unexpected tabs found.
Open

    /**
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    }
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            $key = $row['charA'];
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        );
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $php = \preg_replace_callback('/^(\s*)/m', static function ($matches) {
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        // only interested in chars that are confusable with an ascii char
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            return \strcmp($rowA['charA'], $rowB['charA']);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            return $isEmptyOrComment === false;
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        });
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            // remove leading 00 pairs
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            }, \explode(' ', $parts['charACodePoint']))),
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            'charADesc' => $parts['charADesc'],
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            $isCharAAscii = \strlen($row['charA']) === 1 && \ord($row['charA']) < 0x80;
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            unset($row['charA']);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    {
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            'charA' => \implode('', \array_map(static function ($hex) {
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    protected static function varExportPretty($val)
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $php = \var_export($val, true);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            $isCharBAscii = \strlen($row['charB']) === 1 && \ord($row['charB']) < 0x80;
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        foreach ($rows as $row) {
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        return $rowsNew;
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $parts['charBCodePoint'] = \implode(' ', \array_map(static function ($codePoint) {
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            // remove leading 00 pairs
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            'charACodePoint' => $parts['charACodePoint'],
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    public static $filepathSrc = 'https://www.unicode.org/Public/security/latest/confusables.txt';
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        \file_put_contents($filepathOut, $php);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        \usort($rows, static function ($rowA, $rowB) {
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

                'desc' => $row['charADesc'],
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    }
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $parts = \array_map('trim', $parts);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        }, \explode(' ', $parts['charBCodePoint'])));
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

                return \mb_chr($codePoint, 'UTF-8');
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            }, \explode(' ', $parts['charBCodePoint']))),
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    }
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        }, $php);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    private static function getParsedRows()
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $parts = \array_merge($parts, $matches);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $php = \preg_replace('/=> \n\s+array/', '=> array', $php);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    /** @var string */
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    {
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        });
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    protected static function parseRow($row)
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $parts = \array_combine(['charACodePoint', 'charBCodePoint', 'comment'], $parts);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    protected $charData = array();
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    {
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            return $isCharAAscii === false && $isCharBAscii;
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        // rekey
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    /**
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $parts = \explode(';    ', $row, 3);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            return \preg_replace('/^(00)+/', '', $codePoint);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    public static function update()
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            . 'return ' . self::varExportPretty(self::build()) . ";\n";
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    /**
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $rows = \array_filter($rows, static function ($row) {
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        });
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        \ksort($rowsNew);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    }
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

                return \mb_chr($codePoint, 'UTF-8');
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            'charB' => \implode('', \array_map(static function ($hex) {
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $php = \str_replace('array (', 'array(', $php);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            return \str_repeat($matches[1], 2);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $filepathOut = __DIR__ . '/../src/Debug/Dump/charData.php';
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $rows = \file(self::$filepathSrc);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        }, $rows);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    /**
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            'isXid' => empty($parts['notXid']),
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $php = '<?php // phpcs:ignore SlevomatCodingStandard.Files.FileLength' . "\n\n"
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    public static function build()
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        // not interested in ascii chars that are confusable with other ascii chars
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            if (isset($rowsNew[$key])) {
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            $isEmptyOrComment = \strlen(\trim($row)) === 0 || $row[0] === '#';
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        return \array_map(static function ($row) {
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        \preg_match('/^(?P<category>\w+)\t#(?P<notXid>\*?)\s*(?P<example>\(.*?\))\s*(?P<charADesc>.*?) → (?P<charBDesc>.*?)(\s+#.*)?$/u', $parts['comment'], $matches);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $rows = self::getParsedRows();
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $rows = \array_filter($rows, static function ($row) {
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    {
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            }
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

                'codePoint' => $row['charACodePoint'],
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    {
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

                $codePoint = \hexdec($hex);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

                $codePoint = \hexdec($hex);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            return \preg_replace('/^(00)+/', '', $codePoint);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        return array(
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        return $php;
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    }
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $rowsNew = require __DIR__ . '/charData.php';
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

                continue;
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            $rowsNew[$key] = array(
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            );
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        }
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

            return self::parseRow($row);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        }, \explode(' ', $parts['charACodePoint'])));
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

    /**
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

                'similarTo' => $row['charB'],
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $parts['charACodePoint'] = \implode(' ', \array_map(static function ($codePoint) {
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

Unexpected tabs found.
Open

        $php = \str_replace('\'\' . "\0" . \'\'', '"\x00"', $php);
Severity: Minor
Found in dev/UpdateCharData.php by editorconfig

There are no issues that match your filters.

Category
Status