XoopsModules25x/xlanguage

View on GitHub

Showing 48 of 589 total issues

Function getPreferredLanguage has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getPreferredLanguage()
    {
        $langs = [];
        $lang  = '';
        //        if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
Severity: Minor
Found in class/Utility.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 loadTableFromArrayWithReplace has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

function loadTableFromArrayWithReplace($table, $data, $search, $replace)
{
    /** @var \XoopsMySQLDatabase $db */
    $db = \XoopsDatabaseFactory::getDatabaseConnection();

Severity: Minor
Found in testdata/index.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 langDetect has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function langDetect($str = '', $envType = '')
    {
        require dirname(__DIR__) . '/include/vars.php';
        $lang = '';

Severity: Minor
Found in class/Utility.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 getByName has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function getByName($name, $isBase = false)
    {
        $array = [];
        $lang  = null;
        if (empty($name) || \preg_match('/[^a-zA-Z0-9\_\-]/', $name)) {
Severity: Minor
Found in class/LanguageHandler.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 detectLang has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public static function detectLang()
    {
        global  $_SERVER;
        //      if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
        if (Request::hasVar('HTTP_ACCEPT_LANGUAGE', 'SERVER')) {
Severity: Minor
Found in class/Utility.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 getByName has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getByName($name, $isBase = false)
    {
        $array = [];
        $lang  = null;
        if (empty($name) || \preg_match('/[^a-zA-Z0-9\_\-]/', $name)) {
Severity: Minor
Found in class/LanguageHandler.php - About 1 hr to fix

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

        public static function rrmdir($src)
        {
            // Only continue if user is a 'global' Admin
            if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
                return false;
    Severity: Minor
    Found in class/Common/FilesManagement.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 xoops_module_install_xlanguage has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function xoops_module_install_xlanguage(\XoopsModule $module)
    {
        require_once \dirname(__DIR__, 3) . '/mainfile.php';
    
        $moduleDirName = \basename(\dirname(__DIR__));
    Severity: Minor
    Found in include/oninstall.php - About 1 hr to fix

      Method loadTableFromArrayWithReplace has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function loadTableFromArrayWithReplace($table, $data, $search, $replace)
      {
          /** @var \XoopsMySQLDatabase $db */
          $db = \XoopsDatabaseFactory::getDatabaseConnection();
      
      
      Severity: Minor
      Found in testdata/index.php - About 1 hr to fix

        Method prepareVars has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function prepareVars()
            {
                foreach ($this->vars as $k => $v) {
                    $cleanv = $this->cleanVars[$k];
                    switch ($v['data_type']) {
        Severity: Minor
        Found in class/Blanguage.php - About 1 hr to fix

          Method getServerStats has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function getServerStats()
              {
                  //mb    $wfdownloads = WfdownloadsWfdownloads::getInstance();
                  $moduleDirName      = \basename(\dirname(__DIR__, 2));
                  $moduleDirNameUpper = mb_strtoupper($moduleDirName);
          Severity: Minor
          Found in class/Common/ServerStats.php - About 1 hr to fix

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

                public function prepareVars()
                {
                    foreach ($this->vars as $k => $v) {
                        $cleanv = $this->cleanVars[$k];
                        switch ($v['data_type']) {
            Severity: Minor
            Found in class/Blanguage.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 loadSampleData has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function loadSampleData()
            {
                global $xoopsConfig;
                $moduleDirName      = \basename(\dirname(__DIR__));
                $moduleDirNameUpper = mb_strtoupper($moduleDirName);
            Severity: Minor
            Found in testdata/index.php - About 1 hr to fix

              Method detectLang has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function detectLang()
                  {
                      global  $_SERVER;
                      //      if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
                      if (Request::hasVar('HTTP_ACCEPT_LANGUAGE', 'SERVER')) {
              Severity: Minor
              Found in class/Utility.php - About 1 hr to fix

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

                    public function createConfig()
                    {
                        $file_config = \XLANGUAGE_CONFIG_FILE;
                        if (\is_file($file_config)) {
                            \unlink($file_config);
                Severity: Minor
                Found in class/LanguageHandler.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 rmove has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function rmove($src, $dest)
                    {
                        // Only continue if user is a 'global' Admin
                        if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
                            return false;
                Severity: Minor
                Found in class/Common/FilesManagement.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 rcopy has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function rcopy($src, $dest)
                    {
                        // Only continue if user is a 'global' Admin
                        if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
                            return false;
                Severity: Minor
                Found in class/Common/FilesManagement.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 get has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function get($id, $isBase = true)
                    {
                        $array = [];
                        $lang  = null;
                        $id    = (int)$id;
                Severity: Minor
                Found in class/LanguageHandler.php - About 45 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 getAll has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function getAll($isBase = true)
                    {
                        $prefix = $isBase ? 'xlanguage_base' : 'xlanguage_ext';
                        $ret    = [];
                        if (isset($this->cachedConfig[$prefix])) {
                Severity: Minor
                Found in class/LanguageHandler.php - About 45 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 deeply nested control flow statements.
                Open

                                            if ('html' === $fileInfo->getExtension() && 'index.html' !== $fileInfo->getFilename()) {
                                                if (is_file($templateFolder . $v)) {
                                                    unlink($templateFolder . $v);
                                                }
                                            }
                Severity: Major
                Found in include/onupdate.php - About 45 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language