imagecms/ImageCMS

View on GitHub
application/modules/translator/helpers/translator_helper.php

Summary

Maintainability
C
7 hrs
Test Coverage

Method get_language_names has 93 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function get_language_names() {

        $languageCodes = [
                          'ab' => lang('Abkhazian', 'translator', FALSE),
                          'ae' => lang('Avestan', 'translator', FALSE),
Severity: Major
Found in application/modules/translator/helpers/translator_helper.php - About 3 hrs to fix

Function makeCorrectUrl has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    function makeCorrectUrl($from = '', $to = '') {

        $dotsCount = substr_count($to, '..');

        if (substr($from, -1) == '/') {
Severity: Minor
Found in application/modules/translator/helpers/translator_helper.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 getEditorStyles has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    function getEditorStyles() {

        $files = scandir(getModulePath('translator') . '/assets/js/src-min');
        $styles = [];
        foreach ($files as $file) {
Severity: Minor
Found in application/modules/translator/helpers/translator_helper.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 can_edit_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    function can_edit_file($module_name, $entity_type) {

        if (!MAINSITE) {
            return TRUE;
        }
Severity: Minor
Found in application/modules/translator/helpers/translator_helper.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 get_mainsite_url has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    function get_mainsite_url($url) {

        $true_path = preg_replace('/\/language(.*)/', '', $url);

        if (strstr($true_path, './templates/')) {
Severity: Minor
Found in application/modules/translator/helpers/translator_helper.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

There are no issues that match your filters.

Category
Status