jidaikobo-shibata/a11yc

View on GitHub
classes/Validate/Check/FormAndLabels.php

Summary

Maintainability
D
2 days
Test Coverage

Function missMatchForAndId has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    private static function missMatchForAndId($n, $url, $ms)
    {
        if (isset($ms[1]))
        {
            foreach ($ms[0] as $m)
Severity: Minor
Found in classes/Validate/Check/FormAndLabels.php - About 3 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 uniqueLabel has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    private static function uniqueLabel($k, $url, $whole_form, $v)
    {
        preg_match_all("/\<label[^\>]*?\>(.+?)\<\/label\>/is", $whole_form, $ms);

        if (isset($ms[1]))
Severity: Minor
Found in classes/Validate/Check/FormAndLabels.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 collectFormItems has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    private static function collectFormItems($ms)
    {
        $form_items = array('<form ', '</form' ,'<label', '<input', '<select', '<texta', '<butto');
        $forms = array();
        $n = 0;
Severity: Minor
Found in classes/Validate/Check/FormAndLabels.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 check has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function check($url)
    {
        $error_names = array(
            'labelless',
            'submitless',
Severity: Minor
Found in classes/Validate/Check/FormAndLabels.php - About 1 hr to fix

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

        private static function duplicatedNames($k, $url, $whole_form, $v, $action)
        {
            preg_match_all("/\<(?:input|select|textarea) .+?\>/si", $whole_form, $names);
            if (isset($names[0]))
            {
    Severity: Minor
    Found in classes/Validate/Check/FormAndLabels.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 collectFormItems has 35 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static function collectFormItems($ms)
        {
            $form_items = array('<form ', '</form' ,'<label', '<input', '<select', '<texta', '<butto');
            $forms = array();
            $n = 0;
    Severity: Minor
    Found in classes/Validate/Check/FormAndLabels.php - About 1 hr to fix

      Method uniqueLabel has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function uniqueLabel($k, $url, $whole_form, $v)
          {
              preg_match_all("/\<label[^\>]*?\>(.+?)\<\/label\>/is", $whole_form, $ms);
      
              if (isset($ms[1]))
      Severity: Minor
      Found in classes/Validate/Check/FormAndLabels.php - About 1 hr to fix

        Method submitless has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            private static function submitless($n, $url, $v, $action, $uniqued_types, $uniqued_eles)
        Severity: Minor
        Found in classes/Validate/Check/FormAndLabels.php - About 45 mins to fix

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

              public static function check($url)
              {
                  $error_names = array(
                      'labelless',
                      'submitless',
          Severity: Minor
          Found in classes/Validate/Check/FormAndLabels.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 duplicatedNames has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              private static function duplicatedNames($k, $url, $whole_form, $v, $action)
          Severity: Minor
          Found in classes/Validate/Check/FormAndLabels.php - About 35 mins to fix

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

                        static::addErrorToHtml($url, $error_name, static::$error_ids[$url], 'ignores');

            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