bpteam/gd2-php-ocr

View on GitHub

Showing 11 of 11 total issues

File Divider.php has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author: Evgeny Pynykh bpteam22@gmail.com
 */
namespace bpteam\phpOCR;
Severity: Minor
Found in Divider.php - About 2 hrs to fix

    Function read has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function read($imgFile, $template)
        {
            $img = self::openImg($imgFile);
            $imgs = Divider::byChar($img);
            $text = '';
    Severity: Minor
    Found in Recognizer.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 boldText has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        protected static function boldText($img, $bType = self::WIDTH)
        {
            $colorIndexes = self::getColorsIndexTextAndBackground($img);
            $colorTextIndexes = array_flip($colorIndexes['text']);
            $width = imagesx($img);
    Severity: Minor
    Found in Divider.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 byLine has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected static function byLine($img)
        {
            $imgWidth = imagesx($img);
            $imgHeight = imagesy($img);
            $coordinates = self::coordinatesImg($img);
    Severity: Minor
    Found in Divider.php - About 1 hr to fix

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

          public static function findUniqueChar($imgs)
          {
              $templateChars = [];
              foreach ($imgs as $value) {
                  //Img::show($value);
      Severity: Minor
      Found in Recognizer.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 byChar has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function byChar($img)
          {
              $imgWord = self::byWord($img);
              $imgChars = [];
              foreach ($imgWord as $lineKey => $lineValue) {
      Severity: Minor
      Found in Divider.php - About 1 hr to fix

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

            public static function generateTemplateChar($img, $width = 15, $height = 16)
            {
                if (imagesx($img) != $width || imagesy($img) != $height) {
                    $img = Img::resize($img, $width, $height);
                }
        Severity: Minor
        Found in Recognizer.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 byLine has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            protected static function byLine($img)
            {
                $imgWidth = imagesx($img);
                $imgHeight = imagesy($img);
                $coordinates = self::coordinatesImg($img);
        Severity: Minor
        Found in Divider.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 open has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function open($img)
            {
                $format = false;
                if (strlen($img) < 255 && file_exists($img)) {
                    $info = getimagesize($img);
        Severity: Minor
        Found in Img.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 getColorsIndex has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            protected static function getColorsIndex($img)
            {
                $colorsIndex = [];
                $width = imagesx($img);
                $height = imagesy($img);
        Severity: Minor
        Found in Divider.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 byChar has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function byChar($img)
            {
                $imgWord = self::byWord($img);
                $imgChars = [];
                foreach ($imgWord as $lineKey => $lineValue) {
        Severity: Minor
        Found in Divider.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