jidaikobo-shibata/a11yc

View on GitHub
classes/Message.php

Summary

Maintainability
B
6 hrs
Test Coverage

Function getText has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getText($url, $code_str, $place, $key, $num_of_err)
    {
        $yml = Yaml::fetch();

        $current_err = Validate::setCurrentErr($url, $code_str);
Severity: Minor
Found in classes/Message.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 dt has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function dt($url, $code_str, $place, $key, $current_err, $lv, $num_of_err)
    {
        if ( ! is_array($current_err)) Util::error('invalid value was given');

        $yml = Yaml::fetch();
Severity: Minor
Found in classes/Message.php - About 1 hr to fix

    Method getText has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function getText($url, $code_str, $place, $key, $num_of_err)
        {
            $yml = Yaml::fetch();
    
            $current_err = Validate::setCurrentErr($url, $code_str);
    Severity: Minor
    Found in classes/Message.php - About 1 hr to fix

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

          private static function dt($url, $code_str, $place, $key, $current_err, $lv, $num_of_err)
      Severity: Major
      Found in classes/Message.php - About 50 mins to fix

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

            private static function dt($url, $code_str, $place, $key, $current_err, $lv, $num_of_err)
            {
                if ( ! is_array($current_err)) Util::error('invalid value was given');
        
                $yml = Yaml::fetch();
        Severity: Minor
        Found in classes/Message.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

        Method getText has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public static function getText($url, $code_str, $place, $key, $num_of_err)
        Severity: Minor
        Found in classes/Message.php - About 35 mins to fix

          Avoid using undefined variables such as '$err_cnts' which will lead to PHP notices.
          Open

                      if ( ! isset($current_err['notice'])) Validate::$err_cnts[$lv]++;
          Severity: Minor
          Found in classes/Message.php by phpmd

          UndefinedVariable

          Since: 2.8.0

          Detects when a variable is used that has not been defined before.

          Example

          class Foo
          {
              private function bar()
              {
                  // $message is undefined
                  echo $message;
              }
          }

          Source https://phpmd.org/rules/cleancode.html#undefinedvariable

          There are no issues that match your filters.

          Category
          Status