Method parseDateFormat
has 120 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function parseDateFormat( $format ) {
$length = strlen( $format );
$number = $this->getNumberPattern();
$notFollowedByNumber = '(?!' . $number . ')';
Function parseDateFormat
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
private function parseDateFormat( $format ) {
$length = strlen( $format );
$number = $this->getNumberPattern();
$notFollowedByNumber = '(?!' . $number . ')';
- Read upRead up
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 stringParse
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
protected function stringParse( $value ) {
$date = $this->parseDate( $value );
$precision = TimeValue::PRECISION_YEAR;
$time = [ $this->parseFormattedNumber( $date['year'] ), 0, 0, 0, 0, 0 ];
- Read upRead up
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 DateFormatParser.php
has 259 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace Wikibase\Repo\Parsers;
use DataValues\IllegalValueException;
Consider simplifying this complex logical expression. Open
if ( !isset( $matches['year'] )
|| ( isset( $matches['day'] ) && !isset( $matches['month'] ) )
|| ( isset( $matches['hour'] ) && !isset( $matches['day'] ) )
|| ( isset( $matches['minute'] ) && !isset( $matches['hour'] ) )
|| ( isset( $matches['second'] ) && !isset( $matches['minute'] ) )
Method stringParse
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function stringParse( $value ) {
$date = $this->parseDate( $value );
$precision = TimeValue::PRECISION_YEAR;
$time = [ $this->parseFormattedNumber( $date['year'] ), 0, 0, 0, 0, 0 ];
Function parseDate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function parseDate( $input ) {
$pattern = $this->parseDateFormat( $this->getDateFormat() );
AtEase::suppressWarnings();
$success = preg_match( $pattern, $input, $matches );
- Read upRead up
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 deeply nested control flow statements. Open
if ( isset( $date['second'] ) ) {
$precision = TimeValue::PRECISION_SECOND;
$time[5] = $this->parseFormattedNumber( $date['second'] );
}