XoopsModules25x/xlanguage

View on GitHub

Showing 589 of 589 total issues

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

<?php 

/**
 * xLanguage module (eXtensible Language Management For XOOPS)
 *
Severity: Major
Found in language/tchinese_utf8/admin.php and 1 other location - About 2 days to fix
language/english/admin.php on lines 1..56

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 417.

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

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

<?php

/**
 * xLanguage module (eXtensible Language Management For XOOPS)
 *
Severity: Major
Found in language/english/admin.php and 1 other location - About 2 days to fix
language/tchinese_utf8/admin.php on lines 1..58

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 417.

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

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

<?php
// $Id: modinfo.php,v 1.2 2004/09/27 20:36:31 phppp Exp $
// Module Info

define("_MI_XLANGUAGE_NAME","設置多種語言");
Severity: Major
Found in language/tchinese_utf8/modinfo.php and 1 other location - About 1 day to fix
language/english/modinfo.php on lines 1..41

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 373.

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

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

<?php
//
// Module Info

define('_MI_XLANGUAGE_NAME', 'xLanguage');
Severity: Major
Found in language/english/modinfo.php and 1 other location - About 1 day to fix
language/tchinese_utf8/modinfo.php on lines 1..42

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 373.

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

Function xoops_module_update_xlanguage has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
Open

function xoops_module_update_xlanguage(\XoopsModule $module, $previousVersion = null)
{
    $moduleDirName = \basename(\dirname(__DIR__));

    $utility      = new Utility();
Severity: Minor
Found in include/onupdate.php - About 1 day 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 truncateHtml has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

    public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
    {
        $open_tags = [];
        if ($considerHtml) {
            // if the plain text is shorter than the maximum length, return the whole text
Severity: Minor
Found in class/Common/SysUtility.php - About 1 day 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 showSelectedLanguage has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    public static function showSelectedLanguage($options = null)
    {
        require_once XOOPS_ROOT_PATH . '/modules/xlanguage/blocks/xlanguage_blocks.php';
        if (empty($options)) {
            $options[0] = 'images'; // display style: image, text, select
Severity: Minor
Found in class/Utility.php - About 5 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 languageList has 97 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function languageList(LanguageHandler $languageHandler)
{
    //    global $languageHandler, $xoopsModule;

    global $pathIcon16;
Severity: Major
Found in admin/main.php - About 3 hrs to fix

    Function b_xlanguage_select_show has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    function b_xlanguage_select_show($options)
    {
        global $xlanguage;
    
        $block = [];
    Severity: Minor
    Found in blocks/xlanguage_blocks.php - About 3 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

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

    class Utility extends Common\SysUtility
    {
        //--------------- Custom module methods -----------------------------
        /**
         * @param $value
    Severity: Minor
    Found in class/Utility.php by phpmd

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

    class LanguageHandler extends XoopsObjectHandler
    {
        public $cachedConfig;
    
        public function loadConfig()
    Severity: Minor
    Found in class/LanguageHandler.php by phpmd

    Function languageList has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    function languageList(LanguageHandler $languageHandler)
    {
        //    global $languageHandler, $xoopsModule;
    
        global $pathIcon16;
    Severity: Minor
    Found in admin/main.php - About 3 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 deleteDirectory has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function deleteDirectory($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 3 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

    File LanguageHandler.php has 290 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace XoopsModules\Xlanguage;
    
    /**
    Severity: Minor
    Found in class/LanguageHandler.php - About 2 hrs to fix

      Function checkVerModule has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function checkVerModule($helper, $source = 'github', $default = 'master')
          {
              $moduleDirName      = \basename(\dirname(__DIR__, 2));
              $moduleDirNameUpper = mb_strtoupper($moduleDirName);
              $update             = '';
      Severity: Minor
      Found in class/Common/VersionChecks.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 insert has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function insert($lang)
          {
              $val_array = [];
              if (!$lang->isDirty()) {
                  return true;
      Severity: Major
      Found in class/LanguageHandler.php - About 2 hrs to fix

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

            public function insert($lang)
            {
                $val_array = [];
                if (!$lang->isDirty()) {
                    return true;
        Severity: Minor
        Found in class/LanguageHandler.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 truncateHtml has 63 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
            {
                $open_tags = [];
                if ($considerHtml) {
                    // if the plain text is shorter than the maximum length, return the whole text
        Severity: Major
        Found in class/Common/SysUtility.php - About 2 hrs to fix

          Method b_xlanguage_select_show has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function b_xlanguage_select_show($options)
          {
              global $xlanguage;
          
              $block = [];
          Severity: Major
          Found in blocks/xlanguage_blocks.php - About 2 hrs to fix

            Method xoops_module_update_xlanguage has 56 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function xoops_module_update_xlanguage(\XoopsModule $module, $previousVersion = null)
            {
                $moduleDirName = \basename(\dirname(__DIR__));
            
                $utility      = new Utility();
            Severity: Major
            Found in include/onupdate.php - About 2 hrs to fix
              Severity
              Category
              Status
              Source
              Language