imagecms/ImageCMS

View on GitHub
application/libraries/SiteInfo.php

Summary

Maintainability
D
2 days
Test Coverage

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

    public function normalizeData() {
        if ($this->useLocales == TRUE) {
            // deleting non locale fields from data array (except those what are present $this->nonLocaleKeys)
            foreach ($this->siteinfo as $key => $value) {
                if (!in_array($key, $this->locales) & !in_array($key, $this->nonLocaleKeys)) {
Severity: Minor
Found in application/libraries/SiteInfo.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 getSiteInfoData has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function getSiteInfoData($byLocale = FALSE) {
        if ($this->useLocales == TRUE & $byLocale !== FALSE) {
            if (is_string($byLocale) & in_array($byLocale, $this->locales)) {
                $locale = $byLocale;
            } else {
Severity: Minor
Found in application/libraries/SiteInfo.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 setSiteInfoData has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    public function setSiteInfoData(array $siteInfo) {

        $languages = CI::$APP->db->get('languages')->result_array();

        if ($this->useLocales === TRUE) {
Severity: Minor
Found in application/libraries/SiteInfo.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 getSiteInfo has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function getSiteInfo($name = NULL) {
        // simple checks just in case
        if (!is_string($name)) {
            return '';
        }
Severity: Minor
Found in application/libraries/SiteInfo.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 setSiteInfoValue has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function setSiteInfoValue($key, $value, $contacts = FALSE) {
        if (0 !== strpos($key, 'siteinfo_')) {
            $key = 'siteinfo_' . $key;
        }

Severity: Minor
Found in application/libraries/SiteInfo.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 getSiteInfo has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getSiteInfo($name = NULL) {
        // simple checks just in case
        if (!is_string($name)) {
            return '';
        }
Severity: Minor
Found in application/libraries/SiteInfo.php - About 1 hr to fix

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

    private function contactsKeys($key, $lang) {
        $siteinfoAll = $this->getSiteInfoData(FALSE);
        $locale = MY_Controller::getCurrentLocale();
        $keysMain = [];

Severity: Minor
Found in application/libraries/SiteInfo.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 deleteSiteInfoValue has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function deleteSiteInfoValue($key, $contacts = FALSE) {
        if (0 !== strpos($key, 'siteinfo_')) {
            $key = 'siteinfo_' . $key;
        }
        if ($this->useLocales != TRUE || in_array($key, $this->nonLocaleKeys)) {
Severity: Minor
Found in application/libraries/SiteInfo.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 __construct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct($locale = NULL) {
        if ($this->useLocales === TRUE) {
            $this->locale = $locale !== null ? $locale : MY_Controller::getCurrentLocale();
        }

Severity: Minor
Found in application/libraries/SiteInfo.php - About 35 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 too many return statements within this method.
Open

                    return $this->siteinfo['contacts'][$nameTemp];
Severity: Major
Found in application/libraries/SiteInfo.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return '';
Severity: Major
Found in application/libraries/SiteInfo.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return false;
Severity: Major
Found in application/libraries/SiteInfo.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return $siteinfo[$name];
Severity: Major
Found in application/libraries/SiteInfo.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return '';
Severity: Major
Found in application/libraries/SiteInfo.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

            return $siteinfo['contacts'][$name];
Severity: Major
Found in application/libraries/SiteInfo.php - About 30 mins to fix

There are no issues that match your filters.

Category
Status