qcminecraft/Carbon-Forum-F

View on GitHub
language/auto_translate.php

Summary

Maintainability
F
3 days
Test Coverage

Function ListDir has a Cognitive Complexity of 134 (exceeds 5 allowed). Consider refactoring.
Open

function ListDir($dir)
{
    global $LanguageList;
    if (is_dir($dir)) {
        if ($dh = opendir($dir)) {
Severity: Minor
Found in language/auto_translate.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 ListDir has 105 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function ListDir($dir)
{
    global $LanguageList;
    if (is_dir($dir)) {
        if ($dh = opendir($dir)) {
Severity: Major
Found in language/auto_translate.php - About 4 hrs to fix

    Function translate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    function translate(&$ChineseLang, &$CurrentLang, &$CompareFlag, $language_name)
    {
        $diff = array_diff_key($ChineseLang, $CurrentLang);
        if (!empty($diff)) {
            if ($CompareFlag === false) {
    Severity: Minor
    Found in language/auto_translate.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 translate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function translate(&$ChineseLang, &$CurrentLang, &$CompareFlag, $language_name)
    {
        $diff = array_diff_key($ChineseLang, $CurrentLang);
        if (!empty($diff)) {
            if ($CompareFlag === false) {
    Severity: Minor
    Found in language/auto_translate.php - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                              switch ($file_extension) {
                                  // PHP语言文件翻译
                                  case "php":
                                      $template = __DIR__ . '/language_template.php';
      
      
      Severity: Major
      Found in language/auto_translate.php - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status