qcubed/framework

View on GitHub
includes/framework/QTranslationPoParser.class.php

Summary

Maintainability
F
5 days
Test Coverage

Function ParsePoData has a Cognitive Complexity of 112 (exceeds 5 allowed). Consider refactoring.
Open

    protected function ParsePoData($strPoData) {
        $strPoData = str_replace("\r", '', trim($strPoData));
        $strPoLines = explode("\n", $strPoData);

        $strMatches = array();
Severity: Minor
Found in includes/framework/QTranslationPoParser.class.php - About 2 days 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 ParsePoData has 126 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function ParsePoData($strPoData) {
        $strPoData = str_replace("\r", '', trim($strPoData));
        $strPoLines = explode("\n", $strPoData);

        $strMatches = array();
Severity: Major
Found in includes/framework/QTranslationPoParser.class.php - About 5 hrs to fix

    The class QTranslationPoParser has an overall complexity of 69 which is very high. The configured complexity threshold is 50.
    Open

    class QTranslationPoParser implements QTranslationBase {
        public static function Initialize() {
            return self::Load(QApplication::$LanguageCode, QApplication::$CountryCode);
        }
    
    

    Function Load has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function Load($strLanguageCode = null, $strCountryCode = null) {
            $objLanguageObject = null;
            if ($strLanguageCode) {
                if ($strCountryCode) {
                    $strCode = sprintf('%s_%s', $strLanguageCode, $strCountryCode);
    Severity: Minor
    Found in includes/framework/QTranslationPoParser.class.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 UnescapeContent has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        protected static function UnescapeContent($strContent) {
            $intLength = strlen($strContent);
            $strToReturn = '';
            $blnEscape = false;
    
    
    Severity: Minor
    Found in includes/framework/QTranslationPoParser.class.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

    Method UnescapeContent has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected static function UnescapeContent($strContent) {
            $intLength = strlen($strContent);
            $strToReturn = '';
            $blnEscape = false;
    
    
    Severity: Minor
    Found in includes/framework/QTranslationPoParser.class.php - About 1 hr to fix

      Method Load has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function Load($strLanguageCode = null, $strCountryCode = null) {
              $objLanguageObject = null;
              if ($strLanguageCode) {
                  if ($strCountryCode) {
                      $strCode = sprintf('%s_%s', $strLanguageCode, $strCountryCode);
      Severity: Minor
      Found in includes/framework/QTranslationPoParser.class.php - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                                    if (strlen(trim($strMessageId[$intArrayIndex])) == 0)
                                    throw new QPoParserException('No MsgId for MsgStr' . $strMatches[1][0] . ' for PoParseStateMessageString on Line ' . ($intLineNumber + 1) . ': ' . $strPoLine);
        Severity: Major
        Found in includes/framework/QTranslationPoParser.class.php - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                      if ($strContent === false)
                                      throw new QPoParserException('Invalid content on Line ' . ($intLineNumber + 1));
          Severity: Major
          Found in includes/framework/QTranslationPoParser.class.php - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if ($strContent === false)
                                        throw new QPoParserException('Invalid content on Line ' . ($intLineNumber + 1));
            Severity: Major
            Found in includes/framework/QTranslationPoParser.class.php - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                          if ($strContent === false)
                                          throw new QPoParserException('Invalid content on Line ' . ($intLineNumber + 1));
              Severity: Major
              Found in includes/framework/QTranslationPoParser.class.php - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                            if (strlen(trim($strMessageId[$intArrayIndex])) == 0)
                                            throw new QPoParserException('No MsgId content for current MsgId on Line ' . ($intLineNumber) . ': ' . $strPoLine);
                Severity: Major
                Found in includes/framework/QTranslationPoParser.class.php - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                              if (strlen(trim($strMessageId[$intArrayIndex])) == 0)
                                              throw new QPoParserException('No MsgId content for current MsgId on Line ' . ($intLineNumber) . ': ' . $strPoLine);
                  Severity: Major
                  Found in includes/framework/QTranslationPoParser.class.php - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                if ($strContent === false)
                                                throw new QPoParserException('Invalid content on Line ' . ($intLineNumber + 1));
                    Severity: Major
                    Found in includes/framework/QTranslationPoParser.class.php - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                  for ($intIndex = 0; $intIndex < count($strMessageId); $intIndex++)
                                                  if (strlen(trim($strMessageId[$intIndex]))) {
                                                      if (!strlen(trim($strMessageString[$intIndex]))) {
                                                          $this->SetTranslation($strMessageId[$intIndex], "");
                                                      }
                      Severity: Major
                      Found in includes/framework/QTranslationPoParser.class.php - About 45 mins to fix

                        The method ParsePoData() has an NPath complexity of 2824. The configured NPath complexity threshold is 200.
                        Open

                            protected function ParsePoData($strPoData) {
                                $strPoData = str_replace("\r", '', trim($strPoData));
                                $strPoLines = explode("\n", $strPoData);
                        
                                $strMatches = array();

                        NPathComplexity

                        Since: 0.1

                        The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                        Example

                        class Foo {
                            function bar() {
                                // lots of complicated code
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#npathcomplexity

                        The method ParsePoData() has 153 lines of code. Current threshold is set to 100. Avoid really long methods.
                        Open

                            protected function ParsePoData($strPoData) {
                                $strPoData = str_replace("\r", '', trim($strPoData));
                                $strPoLines = explode("\n", $strPoData);
                        
                                $strMatches = array();

                        The method UnescapeContent() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                        Open

                            protected static function UnescapeContent($strContent) {
                                $intLength = strlen($strContent);
                                $strToReturn = '';
                                $blnEscape = false;
                        
                        

                        CyclomaticComplexity

                        Since: 0.1

                        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                        Example

                        // Cyclomatic Complexity = 11
                        class Foo {
                        1   public function example() {
                        2       if ($a == $b) {
                        3           if ($a1 == $b1) {
                                        fiddle();
                        4           } elseif ($a2 == $b2) {
                                        fiddle();
                                    } else {
                                        fiddle();
                                    }
                        5       } elseif ($c == $d) {
                        6           while ($c == $d) {
                                        fiddle();
                                    }
                        7        } elseif ($e == $f) {
                        8           for ($n = 0; $n < $h; $n++) {
                                        fiddle();
                                    }
                                } else {
                                    switch ($z) {
                        9               case 1:
                                            fiddle();
                                            break;
                        10              case 2:
                                            fiddle();
                                            break;
                        11              case 3:
                                            fiddle();
                                            break;
                                        default:
                                            fiddle();
                                            break;
                                    }
                                }
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                        The method ParsePoData() has a Cyclomatic Complexity of 45. The configured cyclomatic complexity threshold is 10.
                        Open

                            protected function ParsePoData($strPoData) {
                                $strPoData = str_replace("\r", '', trim($strPoData));
                                $strPoLines = explode("\n", $strPoData);
                        
                                $strMatches = array();

                        CyclomaticComplexity

                        Since: 0.1

                        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                        Example

                        // Cyclomatic Complexity = 11
                        class Foo {
                        1   public function example() {
                        2       if ($a == $b) {
                        3           if ($a1 == $b1) {
                                        fiddle();
                        4           } elseif ($a2 == $b2) {
                                        fiddle();
                                    } else {
                                        fiddle();
                                    }
                        5       } elseif ($c == $d) {
                        6           while ($c == $d) {
                                        fiddle();
                                    }
                        7        } elseif ($e == $f) {
                        8           for ($n = 0; $n < $h; $n++) {
                                        fiddle();
                                    }
                                } else {
                                    switch ($z) {
                        9               case 1:
                                            fiddle();
                                            break;
                        10              case 2:
                                            fiddle();
                                            break;
                        11              case 3:
                                            fiddle();
                                            break;
                                        default:
                                            fiddle();
                                            break;
                                    }
                                }
                            }
                        }

                        Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                        Missing class import via use statement (line '250', column '18').
                        Open

                                                    throw new QPoParserException('Invalid content on Line ' . ($intLineNumber + 1));

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '30', column '20').
                        Open

                                    $objCache = new QCache('i18n.po', $strCode, 'i18n', $strLanguageFiles);

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '208', column '17').
                        Open

                                                throw new QPoParserException('Invalid content for PoParseStateMessageStringStart on Line ' . ($intLineNumber + 1) . ': ' . $strPoLine);

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '39', column '24').
                        Open

                                        $objLanguage = new QTranslationPoParser();

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '165', column '18').
                        Open

                                                    throw new QPoParserException('No MsgId content for current MsgId on Line ' . ($intLineNumber) . ': ' . $strPoLine);

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '158', column '17').
                        Open

                                                throw new QPoParserException('Invalid content for PoParseStateMessageIdStart on Line ' . ($intLineNumber + 1) . ': ' . $strPoLine);

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '204', column '18').
                        Open

                                                    throw new QPoParserException('Invalid content on Line ' . ($intLineNumber + 1));

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '258', column '17').
                        Open

                                                throw new QPoParserException('Invalid PoParseState on Line ' . ($intLineNumber + 1) . ': ' . $strPoLine);

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '192', column '17').
                        Open

                                                throw new QPoParserException('Invalid content for PoParseStateMessageId on Line ' . ($intLineNumber + 1) . ': ' . $strPoLine);

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '142', column '17').
                        Open

                                                throw new QPoParserException('Invalid content for PoParseStateNone on Line ' . ($intLineNumber + 1) . ': ' . $strPoLine);

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '246', column '18').
                        Open

                                                    throw new QPoParserException('No MsgId for MsgStr' . $strMatches[1][0] . ' for PoParseStateMessageString on Line ' . ($intLineNumber + 1) . ': ' . $strPoLine);

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '186', column '18').
                        Open

                                                    throw new QPoParserException('No MsgId content for current MsgId on Line ' . ($intLineNumber) . ': ' . $strPoLine);

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '243', column '18').
                        Open

                                                    throw new QPoParserException('No index specified for alternate MsgStr for PoParseStateMessageString on Line ' . ($intLineNumber + 1) . ': ' . $strPoLine);

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '154', column '18').
                        Open

                                                    throw new QPoParserException('Invalid content on Line ' . ($intLineNumber + 1));

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '169', column '18').
                        Open

                                                    throw new QPoParserException('Invalid content on Line ' . ($intLineNumber + 1));

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '255', column '17').
                        Open

                                                throw new QPoParserException('Invalid content for PoParseStateMessageString on Line ' . ($intLineNumber + 1) . ': ' . $strPoLine);

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '178', column '18').
                        Open

                                                    throw new QPoParserException('Invalid content on Line ' . ($intLineNumber + 1));

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        Missing class import via use statement (line '232', column '18').
                        Open

                                                    throw new QPoParserException('Invalid content on Line ' . ($intLineNumber + 1));

                        MissingImport

                        Since: 2.7.0

                        Importing all external classes in a file through use statements makes them clearly visible.

                        Example

                        function make() {
                            return new \stdClass();
                        }

                        Source http://phpmd.org/rules/cleancode.html#MissingImport

                        The method Load uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                    } else {
                                        $strCode = $strLanguageCode;
                                        $strLanguageFiles = array(
                                        __QCUBED_CORE__ . '/i18n/' . $strLanguageCode . '.po',
                                        __QI18N_PO_PATH__ . '/' . $strLanguageCode . '.po'

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        The method UnescapeContent uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                    } else {
                                        if ($strContent[$intIndex] == '\\')
                                        $blnEscape = true;
                                        else
                                        $strToReturn .= $strContent[$intIndex];

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        Avoid using static access to class 'QTranslationPoParser' in method 'ParsePoData'.
                        Open

                                                    $strContent = QTranslationPoParser::UnescapeContent($strMatches[2][0]);

                        StaticAccess

                        Since: 1.4.0

                        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                        Example

                        class Foo
                        {
                            public function bar()
                            {
                                Bar::baz();
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#staticaccess

                        Avoid using static access to class 'QTranslationPoParser' in method 'ParsePoData'.
                        Open

                                                    $strContent = QTranslationPoParser::UnescapeContent($strMatches[1][0]);

                        StaticAccess

                        Since: 1.4.0

                        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                        Example

                        class Foo
                        {
                            public function bar()
                            {
                                Bar::baz();
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#staticaccess

                        The method Load uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                    } else {
                                        $objLanguage = new QTranslationPoParser();
                                            
                                        foreach ($strLanguageFiles as $strLanguageFile) {
                                            if (file_exists($strLanguageFile)) {

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        Avoid using static access to class 'QTranslationPoParser' in method 'ParsePoData'.
                        Open

                                                    $strContent = QTranslationPoParser::UnescapeContent($strMatches[2][0]);

                        StaticAccess

                        Since: 1.4.0

                        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                        Example

                        class Foo
                        {
                            public function bar()
                            {
                                Bar::baz();
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#staticaccess

                        Avoid using static access to class 'QApplication' in method 'VarDump'.
                        Open

                                    $strValue = str_replace("\n", '\\n', addslashes(QApplication::HtmlEntities($strValue)));

                        StaticAccess

                        Since: 1.4.0

                        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                        Example

                        class Foo
                        {
                            public function bar()
                            {
                                Bar::baz();
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#staticaccess

                        Avoid using static access to class 'QTranslationPoParser' in method 'ParsePoData'.
                        Open

                                                    $strContent = QTranslationPoParser::UnescapeContent($strMatches[2][0]);

                        StaticAccess

                        Since: 1.4.0

                        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                        Example

                        class Foo
                        {
                            public function bar()
                            {
                                Bar::baz();
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#staticaccess

                        Avoid using static access to class 'QApplication' in method 'VarDump'.
                        Open

                                    $strKey = str_replace("\n", '\\n', addslashes(QApplication::HtmlEntities($strKey)));

                        StaticAccess

                        Since: 1.4.0

                        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                        Example

                        class Foo
                        {
                            public function bar()
                            {
                                Bar::baz();
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#staticaccess

                        Avoid using static access to class 'QString' in method 'ParsePoData'.
                        Open

                                    if (strlen($strPoLine) && (QString::FirstCharacter($strPoLine) != '#')) {

                        StaticAccess

                        Since: 1.4.0

                        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                        Example

                        class Foo
                        {
                            public function bar()
                            {
                                Bar::baz();
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#staticaccess

                        Avoid using static access to class 'QTranslationPoParser' in method 'ParsePoData'.
                        Open

                                                    $strContent = QTranslationPoParser::UnescapeContent($strMatches[1][0]);

                        StaticAccess

                        Since: 1.4.0

                        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                        Example

                        class Foo
                        {
                            public function bar()
                            {
                                Bar::baz();
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#staticaccess

                        Avoid using static access to class 'QTranslationPoParser' in method 'ParsePoData'.
                        Open

                                                    $strContent = QTranslationPoParser::UnescapeContent($strMatches[2][0]);

                        StaticAccess

                        Since: 1.4.0

                        Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                        Example

                        class Foo
                        {
                            public function bar()
                            {
                                Bar::baz();
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#staticaccess

                        The method TranslateToken uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                        Open

                                } else {
                                    return $strToken;
                                }

                        ElseExpression

                        Since: 1.4.0

                        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                        Example

                        class Foo
                        {
                            public function bar($flag)
                            {
                                if ($flag) {
                                    // one branch
                                } else {
                                    // another branch
                                }
                            }
                        }

                        Source https://phpmd.org/rules/cleancode.html#elseexpression

                        Avoid using count() function in for loops.
                        Open

                                                    for ($intIndex = 0; $intIndex < count($strMessageId); $intIndex++)
                                                    if (strlen(trim($strMessageId[$intIndex]))) {
                                                        if (!strlen(trim($strMessageString[$intIndex]))) {
                                                            $this->SetTranslation($strMessageId[$intIndex], "");
                                                        }

                        CountInLoopExpression

                        Since: 2.7.0

                        Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.

                        Example

                        class Foo {
                        
                          public function bar()
                          {
                            $array = array();
                        
                            for ($i = 0; count($array); $i++) {
                              // ...
                            }
                          }
                        }

                        Source https://phpmd.org/rules/design.html#countinloopexpression

                        Avoid using count() function in for loops.
                        Open

                                for ($intIndex = 0; $intIndex < count($strMessageId); $intIndex++) {
                                    if (strlen(trim($strMessageId[$intIndex]))) {
                                        if (!strlen(trim($strMessageString[$intIndex]))) {
                                            $this->SetTranslation($strMessageId[$intIndex], "");
                                        }

                        CountInLoopExpression

                        Since: 2.7.0

                        Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.

                        Example

                        class Foo {
                        
                          public function bar()
                          {
                            $array = array();
                        
                            for ($i = 0; count($array); $i++) {
                              // ...
                            }
                          }
                        }

                        Source https://phpmd.org/rules/design.html#countinloopexpression

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                                                    for ($intIndex = 0; $intIndex < count($strMessageId); $intIndex++)
                                                    if (strlen(trim($strMessageId[$intIndex]))) {
                                                        if (!strlen(trim($strMessageString[$intIndex]))) {
                                                            $this->SetTranslation($strMessageId[$intIndex], "");
                                                        }
                        Severity: Major
                        Found in includes/framework/QTranslationPoParser.class.php and 1 other location - About 1 hr to fix
                        includes/framework/QTranslationPoParser.class.php on lines 263..270

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 109.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                                for ($intIndex = 0; $intIndex < count($strMessageId); $intIndex++) {
                                    if (strlen(trim($strMessageId[$intIndex]))) {
                                        if (!strlen(trim($strMessageString[$intIndex]))) {
                                            $this->SetTranslation($strMessageId[$intIndex], "");
                                        }
                        Severity: Major
                        Found in includes/framework/QTranslationPoParser.class.php and 1 other location - About 1 hr to fix
                        includes/framework/QTranslationPoParser.class.php on lines 215..221

                        Duplicated Code

                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                        Tuning

                        This issue has a mass of 109.

                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                        Refactorings

                        Further Reading

                        Constant PoParseStateMessageString should be defined in uppercase
                        Open

                            const PoParseStateMessageString = 4;

                        ConstantNamingConventions

                        Since: 0.2

                        Class/Interface constant names should always be defined in uppercase.

                        Example

                        class Foo {
                            const MY_NUM = 0; // ok
                            const myTest = ""; // fail
                        }

                        Source https://phpmd.org/rules/naming.html#constantnamingconventions

                        Constant PoParseStateNone should be defined in uppercase
                        Open

                            const PoParseStateNone = 0;

                        ConstantNamingConventions

                        Since: 0.2

                        Class/Interface constant names should always be defined in uppercase.

                        Example

                        class Foo {
                            const MY_NUM = 0; // ok
                            const myTest = ""; // fail
                        }

                        Source https://phpmd.org/rules/naming.html#constantnamingconventions

                        Constant PoParseStateMessageId should be defined in uppercase
                        Open

                            const PoParseStateMessageId = 2;

                        ConstantNamingConventions

                        Since: 0.2

                        Class/Interface constant names should always be defined in uppercase.

                        Example

                        class Foo {
                            const MY_NUM = 0; // ok
                            const myTest = ""; // fail
                        }

                        Source https://phpmd.org/rules/naming.html#constantnamingconventions

                        Constant PoParseStateMessageStringStart should be defined in uppercase
                        Open

                            const PoParseStateMessageStringStart = 3;

                        ConstantNamingConventions

                        Since: 0.2

                        Class/Interface constant names should always be defined in uppercase.

                        Example

                        class Foo {
                            const MY_NUM = 0; // ok
                            const myTest = ""; // fail
                        }

                        Source https://phpmd.org/rules/naming.html#constantnamingconventions

                        Constant PoParseStateMessageIdStart should be defined in uppercase
                        Open

                            const PoParseStateMessageIdStart = 1;

                        ConstantNamingConventions

                        Since: 0.2

                        Class/Interface constant names should always be defined in uppercase.

                        Example

                        class Foo {
                            const MY_NUM = 0; // ok
                            const myTest = ""; // fail
                        }

                        Source https://phpmd.org/rules/naming.html#constantnamingconventions

                        The method Load is not named in camelCase.
                        Open

                            public static function Load($strLanguageCode = null, $strCountryCode = null) {
                                $objLanguageObject = null;
                                if ($strLanguageCode) {
                                    if ($strCountryCode) {
                                        $strCode = sprintf('%s_%s', $strLanguageCode, $strCountryCode);

                        CamelCaseMethodName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name methods.

                        Example

                        class ClassName {
                            public function get_name() {
                            }
                        }

                        Source

                        The method ParsePoData is not named in camelCase.
                        Open

                            protected function ParsePoData($strPoData) {
                                $strPoData = str_replace("\r", '', trim($strPoData));
                                $strPoLines = explode("\n", $strPoData);
                        
                                $strMatches = array();

                        CamelCaseMethodName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name methods.

                        Example

                        class ClassName {
                            public function get_name() {
                            }
                        }

                        Source

                        The method VarDump is not named in camelCase.
                        Open

                            public function VarDump() {
                                $strToReturn = '';
                                foreach ($this->strTranslationArray as $strKey=>$strValue) {
                                    $strKey = str_replace("\n", '\\n', addslashes(QApplication::HtmlEntities($strKey)));
                                    $strValue = str_replace("\n", '\\n', addslashes(QApplication::HtmlEntities($strValue)));

                        CamelCaseMethodName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name methods.

                        Example

                        class ClassName {
                            public function get_name() {
                            }
                        }

                        Source

                        The method TranslateToken is not named in camelCase.
                        Open

                            public function TranslateToken($strToken) {
                                $strCleanToken = str_replace("\r", '', $strToken);
                                if (array_key_exists($strCleanToken, $this->strTranslationArray)) {
                                    return $this->strTranslationArray[$strCleanToken];
                                } else {

                        CamelCaseMethodName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name methods.

                        Example

                        class ClassName {
                            public function get_name() {
                            }
                        }

                        Source

                        The method Initialize is not named in camelCase.
                        Open

                            public static function Initialize() {
                                return self::Load(QApplication::$LanguageCode, QApplication::$CountryCode);
                            }

                        CamelCaseMethodName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name methods.

                        Example

                        class ClassName {
                            public function get_name() {
                            }
                        }

                        Source

                        The method UnescapeContent is not named in camelCase.
                        Open

                            protected static function UnescapeContent($strContent) {
                                $intLength = strlen($strContent);
                                $strToReturn = '';
                                $blnEscape = false;
                        
                        

                        CamelCaseMethodName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name methods.

                        Example

                        class ClassName {
                            public function get_name() {
                            }
                        }

                        Source

                        The method SetTranslation is not named in camelCase.
                        Open

                            protected function SetTranslation($strToken, $strTranslatedText) {
                                $this->strTranslationArray[$strToken] = $strTranslatedText;
                            }

                        CamelCaseMethodName

                        Since: 0.2

                        It is considered best practice to use the camelCase notation to name methods.

                        Example

                        class ClassName {
                            public function get_name() {
                            }
                        }

                        Source

                        There are no issues that match your filters.

                        Category
                        Status