fossasia/engelsystem

View on GitHub
includes/view/User_view.php

Summary

Maintainability
D
2 days
Test Coverage

Method User_view has 118 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) {
  global $LETZTES_AUSTRAGEN, $privileges;
  $user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']);
  $myshifts_table = array();
  $timesum = 0;
Severity: Major
Found in includes/view/User_view.php - About 4 hrs to fix

    Function User_view has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

    function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) {
      global $LETZTES_AUSTRAGEN, $privileges;
      $user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']);
      $myshifts_table = array();
      $timesum = 0;
    Severity: Minor
    Found in includes/view/User_view.php - About 4 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 User_view.php has 333 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     * Available T-Shirt sizes
     */
    Severity: Minor
    Found in includes/view/User_view.php - About 4 hrs to fix

      Method Users_view has 73 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function Users_view($users, $order_by, $arrived_count, $active_count, $force_active_count, $freeloads_count, $tshirts_count, $voucher_count) {
        $search = "";
        $users_matched = [];
        if (isset($_REQUEST['search']))
          $search = strip_request_item('search');
      Severity: Major
      Found in includes/view/User_view.php - About 2 hrs to fix

        Function Users_view has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        function Users_view($users, $order_by, $arrived_count, $active_count, $force_active_count, $freeloads_count, $tshirts_count, $voucher_count) {
          $search = "";
          $users_matched = [];
          if (isset($_REQUEST['search']))
            $search = strip_request_item('search');
        Severity: Minor
        Found in includes/view/User_view.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 Users_view has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function Users_view($users, $order_by, $arrived_count, $active_count, $force_active_count, $freeloads_count, $tshirts_count, $voucher_count) {
        Severity: Major
        Found in includes/view/User_view.php - About 1 hr to fix

          Method User_view has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) {
          Severity: Major
          Found in includes/view/User_view.php - About 50 mins to fix

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

            function User_angeltypes_render($user_angeltypes) {
              $output = array();
              foreach ($user_angeltypes as $angeltype) {
                $class = "";
                if ($angeltype['restricted'] == 1)
            Severity: Minor
            Found in includes/view/User_view.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 User_shift_state_render has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            function User_shift_state_render($user) {
              $upcoming_shifts = ShiftEntries_upcoming_for_user($user);
              if ($upcoming_shifts === false)
                return false;
            
            
            Severity: Minor
            Found in includes/view/User_view.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 Other_languages_render has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            function Other_languages_render($user_source) {
              $other_langs = explode(",", $user_source['other_languages']);
              $xml = simplexml_load_file("https://www.facebook.com/translations/FacebookLocales.xml");
              $list = "";
              foreach($xml->xpath("/locales/locale") as $item)
            Severity: Minor
            Found in includes/view/User_view.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 '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Shift starts %c") . '</span>';
            Severity: Major
            Found in includes/view/User_view.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                  return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['end'] . '">' . _("Shift ends %c") . '</span>';
              Severity: Major
              Found in includes/view/User_view.php - About 30 mins to fix

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

                    if (count($tokens) > 0) {
                      $match = false;
                      $index = join(" ", $usr);
                      foreach ($tokens as $t)
                        if (stristr($index, trim($t))) {
                Severity: Minor
                Found in includes/view/User_view.php and 2 other locations - About 30 mins to fix
                includes/controller/admin_arrive_controller.php on lines 46..56
                includes/controller/admin_free_controller.php on lines 37..47

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

                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