plugins/content/admin_modules/yf_manage_faq.class.php

Summary

Maintainability
D
2 days
Test Coverage

File yf_manage_faq.class.php has 319 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

class yf_manage_faq
{
    const table = 'faq';
Severity: Minor
Found in plugins/content/admin_modules/yf_manage_faq.class.php - About 3 hrs to fix

    Method edit has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function edit()
        {
            $id = (int) $_GET['id'];
            if ($id) {
                $a = from(self::table)->whereid($id)->get();
    Severity: Minor
    Found in plugins/content/admin_modules/yf_manage_faq.class.php - About 1 hr to fix

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

          public function edit()
          {
              $id = (int) $_GET['id'];
              if ($id) {
                  $a = from(self::table)->whereid($id)->get();
      Severity: Minor
      Found in plugins/content/admin_modules/yf_manage_faq.class.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 _show_for_lang has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function _show_for_lang($lang)
          {
              $_GET['page'] = $lang; // Needed for html()->tree links
              $all = $this->_get_items($lang);
              $items = [];
      Severity: Minor
      Found in plugins/content/admin_modules/yf_manage_faq.class.php - About 1 hr to fix

        Method save has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function save()
            {
                $lang = $_GET['page'];
                if ( ! is_post() || ! $lang || ! isset($this->all_langs[$lang])) {
                    return js_redirect(url('/@object'));
        Severity: Minor
        Found in plugins/content/admin_modules/yf_manage_faq.class.php - About 1 hr to fix

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

              public function save()
              {
                  $lang = $_GET['page'];
                  if ( ! is_post() || ! $lang || ! isset($this->all_langs[$lang])) {
                      return js_redirect(url('/@object'));
          Severity: Minor
          Found in plugins/content/admin_modules/yf_manage_faq.class.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 add has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function add()
              {
                  $a['locale'] = substr($_GET['page'], 0, 2) ?: 'ru';
                  $a['parent_id'] = (int) $_GET['id'];
                  $parent = $a['parent_id'] ? (array) from(self::table)->whereid($a['parent_id'])->get() : [];
          Severity: Minor
          Found in plugins/content/admin_modules/yf_manage_faq.class.php - About 1 hr to fix

            Function _get_parents_for_select has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function _get_parents_for_select($lang, $skip_id = null)
                {
                    $data = [0 => '-- TOP --'];
                    foreach ((array) $this->_recursive_get_items($lang) as $id => $info) {
                        if (empty($id)) {
            Severity: Minor
            Found in plugins/content/admin_modules/yf_manage_faq.class.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 _auto_update_items_orders has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                public function _auto_update_items_orders($lang)
                {
                    if ( ! $lang) {
                        return false;
                    }
            Severity: Minor
            Found in plugins/content/admin_modules/yf_manage_faq.class.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 _count_levels has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function _count_levels($start_id = 0, &$children, $level = 0)
                {
                    $ids = [];
                    foreach ((array) $children[$start_id] as $id => $_tmp) {
                        $ids[$id] = $level;
            Severity: Minor
            Found in plugins/content/admin_modules/yf_manage_faq.class.php - About 25 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

            Identical blocks of code found in 3 locations. Consider refactoring.
            Open

                public function _recursive_sort_items($items = [], $skip_item_id = 0, $parent_id = 0, $level = 0)
                {
                    $children = [];
                    foreach ((array) $items as $id => $info) {
                        $parent_id = $info['parent_id'];
            Severity: Major
            Found in plugins/content/admin_modules/yf_manage_faq.class.php and 2 other locations - About 3 hrs to fix
            plugins/categories/admin_modules/yf_category_editor.class.php on lines 518..534
            plugins/sys/admin_modules/yf_menus_editor.class.php on lines 551..567

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

            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

            Identical blocks of code found in 3 locations. Consider refactoring.
            Open

                    if (is_post()) {
                        foreach ((array) $keys_to_fix as $k) {
                            if (false !== strpos($_POST[$k], '{') && false !== strpos($_POST[$k], '}')) {
                                $_POST[$k] = str_replace(array_values($exec_fix), array_keys($exec_fix), $_POST[$k]);
                            }
            Severity: Major
            Found in plugins/content/admin_modules/yf_manage_faq.class.php and 2 other locations - About 1 hr to fix
            plugins/content/admin_modules/yf_manage_news.class.php on lines 73..79
            plugins/static_pages/admin_modules/yf_static_pages.class.php on lines 103..109

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

            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

                public function _get_parents_for_select($lang, $skip_id = null)
                {
                    $data = [0 => '-- TOP --'];
                    foreach ((array) $this->_recursive_get_items($lang) as $id => $info) {
                        if (empty($id)) {
            Severity: Major
            Found in plugins/content/admin_modules/yf_manage_faq.class.php and 1 other location - About 1 hr to fix
            plugins/sys/admin_modules/yf_menus_editor.class.php on lines 697..710

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

            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

            Identical blocks of code found in 6 locations. Consider refactoring.
            Open

                public function _count_levels($start_id = 0, &$children, $level = 0)
                {
                    $ids = [];
                    foreach ((array) $children[$start_id] as $id => $_tmp) {
                        $ids[$id] = $level;
            Severity: Major
            Found in plugins/content/admin_modules/yf_manage_faq.class.php and 5 other locations - About 1 hr to fix
            plugins/categories/admin_modules/yf_category_editor.class.php on lines 540..552
            plugins/categories/classes/yf_cats.class.php on lines 137..149
            plugins/html/classes/yf_html.class.php on lines 104..116
            plugins/sys/admin_modules/yf_menus_editor.class.php on lines 573..585
            plugins/sys/classes/yf_core_menu.class.php on lines 456..468

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

            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

            There are no issues that match your filters.

            Category
            Status