wikimedia/mediawiki-core

View on GitHub
includes/language/ConverterRule.php

Summary

Maintainability
F
3 days
Test Coverage

Function parse has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
Open

    public function parse( $variant = null ) {
        if ( !$variant ) {
            $variant = $this->mConverter->getPreferredVariant();
        }

Severity: Minor
Found in includes/language/ConverterRule.php - About 6 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 generateConvTable has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    private function generateConvTable() {
        // Special case optimisation
        if ( !$this->mBidtable && !$this->mUnidtable ) {
            $this->mConvTable = [];
            return;
Severity: Minor
Found in includes/language/ConverterRule.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 ConverterRule.php has 332 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
Severity: Minor
Found in includes/language/ConverterRule.php - About 4 hrs to fix

    Function parseFlags has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        private function parseFlags() {
            $text = $this->mText;
            $flags = [];
            $variantFlags = [];
    
    
    Severity: Minor
    Found in includes/language/ConverterRule.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

    Method parse has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function parse( $variant = null ) {
            if ( !$variant ) {
                $variant = $this->mConverter->getPreferredVariant();
            }
    
    
    Severity: Major
    Found in includes/language/ConverterRule.php - About 3 hrs to fix

      Function parseRules has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          private function parseRules() {
              $rules = $this->mRules;
              $bidtable = [];
              $unidtable = [];
              $varsep_pattern = $this->mConverter->getVarSeparatorPattern();
      Severity: Minor
      Found in includes/language/ConverterRule.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 parseFlags has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function parseFlags() {
              $text = $this->mText;
              $flags = [];
              $variantFlags = [];
      
      
      Severity: Major
      Found in includes/language/ConverterRule.php - About 2 hrs to fix

        Method parseRules has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function parseRules() {
                $rules = $this->mRules;
                $bidtable = [];
                $unidtable = [];
                $varsep_pattern = $this->mConverter->getVarSeparatorPattern();
        Severity: Major
        Found in includes/language/ConverterRule.php - About 2 hrs to fix

          Method generateConvTable has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function generateConvTable() {
                  // Special case optimisation
                  if ( !$this->mBidtable && !$this->mUnidtable ) {
                      $this->mConvTable = [];
                      return;
          Severity: Minor
          Found in includes/language/ConverterRule.php - About 1 hr to fix

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

                private function getRuleConvertedStr( $variant ) {
                    $bidtable = $this->mBidtable;
                    $unidtable = $this->mUnidtable;
            
                    if ( count( $bidtable ) + count( $unidtable ) === 0 ) {
            Severity: Minor
            Found in includes/language/ConverterRule.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

            There are no issues that match your filters.

            Category
            Status