Showing 2,096 of 2,096 total issues
Method newImplementation
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function newImplementation(): WikibaseLuaEntityBindings {
$lang = $this->getLanguage();
$snakFormatterFactory = WikibaseClient::getDataAccessSnakFormatterFactory();
$plainTextSnakFormatter = $snakFormatterFactory->newWikitextSnakFormatter(
$lang,
Method injectRCRecords
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function injectRCRecords( array $titles, EntityChange $change, array $rootJobParams = [] ) {
if ( $titles === [] ) {
return;
}
Method getArchiveRows
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getArchiveRows( int &$processed, int &$staleRecords, string $entityIdSerialization ): array {
$dbr = $this->db->connections()->getReadConnection();
$iterator = new BatchRowIterator(
$dbr,
Method getConflictsForItem
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getConflictsForItem( ItemId $itemId, SiteLinkList $siteLinkList, int $db = null ) {
if ( $siteLinkList->isEmpty() ) {
return [];
}
Method addMainSnak
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function addMainSnak( EntityId $entityId, $statementLName, Statement $statement, $isBest ) {
$snak = $statement->getMainSnak();
$entityLName = $this->vocabulary->getEntityLName( $entityId );
$entityRepository = $this->vocabulary->getEntityRepositoryName( $entityId );
Method getDataUpdaters
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getDataUpdaters(): array {
$propertyDataTypeMatcher = new PropertyDataTypeMatcher( $this->propertyDataTypeLookup );
$statementUpdater = new CompositeStatementDataUpdater(
new ExternalLinksDataUpdater( $propertyDataTypeMatcher ),
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 ];
Method getSnakFormatter
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getSnakFormatter( $format, FormatterOptions $options ) {
$options->defaultOption( SnakFormatter::OPT_ON_ERROR, SnakFormatter::ON_ERROR_WARN );
$this->valueFormatterFactory->applyLanguageDefaults( $options );
$lang = $options->getOption( ValueFormatter::OPT_LANG );
Function formatSnak
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function formatSnak( Snak $snak ) {
if ( $snak instanceof PropertyValueSnak ) {
$value = $snak->getDataValue();
// FIXME: All usage tracking is technically misplaced here, as it repeats knowledge from
- 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 dumpEntities
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function dumpEntities( array $entityIds, int &$dumpCount ): void {
$toLoad = [];
foreach ( $entityIds as $entityId ) {
if ( $this->idMatchesFilters( $entityId ) ) {
$toLoad[] = $entityId;
- 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 getChangeOps
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function getChangeOps( Fingerprint $fingerprint ) {
$changeOpFactory = $this->changeOpFactory;
$changeOps = [];
if ( $this->label !== '' ) {
- 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 formatArg
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
protected function formatArg( $arg ) {
try {
if ( $arg instanceof Snak ) {
return $this->snakFormatter->formatSnak( $arg );
} elseif ( $arg instanceof EntityId ) {
- 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 internalDoHtmlPageLinkRendererEnd
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function internalDoHtmlPageLinkRendererEnd(
LinkRenderer $linkRenderer,
Title $target,
&$text,
array &$customAttribs,
- 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 addStatement
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function addStatement( EntityId $entityId, Statement $statement, $isBest ) {
$statementLName = $this->vocabulary->getStatementLName( $statement );
$entityRepository = $this->vocabulary->getEntityRepositoryName( $entityId );
- 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 buildIndexedAliasesChangeOps
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function buildIndexedAliasesChangeOps( array $indexedAliases ) {
$aliasesChangeOps = new ChangeOps();
foreach ( $indexedAliases as $langCode => $serializations ) {
$aliasesToSet = [];
- 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 getEntityRevision
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function getEntityRevision(
EntityId $entityId,
$revisionId = 0,
$mode = LookupConstants::LATEST_FROM_REPLICA
) {
- 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 __construct
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function __construct( iterable $snaks, array $certainPropertyIds ) {
foreach ( $certainPropertyIds as $certainPropertyId ) {
/** @var PropertyId $certainPropertyId */
'@phan-var PropertyId $certainPropertyId';
if ( $certainPropertyId !== null ) {
- 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 prefetchTerms
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function prefetchTerms(
array $entityIds,
array $termTypes,
array $languageCodes
) {
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function getParamSettings(): array {
return [
self::ITEM_ID_PATH_PARAM => [
self::PARAM_SOURCE => 'path',
ParamValidator::PARAM_TYPE => 'string',
- Read upRead up
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 112.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
protected function renderLabelValuePair( $fieldName, $valueHtml ) {
$html = Html::openElement( 'tr' );
$html .= Html::element( 'th', [ 'class' => 'wb-globe-' . $fieldName ],
$this->getFieldLabel( $fieldName )->text() );
- Read upRead up
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 112.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76