Showing 2,096 of 2,096 total issues
Method doSearch
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function doSearch( $query ) {
$limit = (int)$this->getOption( 'limit', 5 );
$results = $this->searchHelper->getRankedSearchResults(
$query,
Method handleDescriptionValidationErrors
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function handleDescriptionValidationErrors( ValidationError $validationError ): void {
$context = $validationError->getContext();
switch ( $validationError->getCode() ) {
case DescriptionsSyntaxValidator::CODE_DESCRIPTIONS_NOT_ASSOCIATIVE:
throw UseCaseError::newInvalidValue( '/item/descriptions' );
Method handleLabelsValidationError
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function handleLabelsValidationError( ValidationError $validationError ): void {
$context = $validationError->getContext();
switch ( $validationError->getCode() ) {
case LabelsSyntaxValidator::CODE_LABELS_NOT_ASSOCIATIVE:
Method execute
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute( PatchItemDescriptionsRequest $request ): PatchItemDescriptionsResponse {
$deserializedRequest = $this->requestValidator->validateAndDeserialize( $request );
$itemId = $deserializedRequest->getItemId();
$this->assertItemExists->execute( $itemId );
Method handleSitelinksValidationErrors
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function handleSitelinksValidationErrors( ValidationError $validationError, array $serialization ): void {
$context = $validationError->getContext();
$siteId = fn() => $context[SitelinkValidator::CONTEXT_SITE_ID];
switch ( $validationError->getCode() ) {
Method makeNormalizer
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function makeNormalizer( PropertyId $propertyId, string $valueType ): DataValueNormalizer {
$dataTypeNormalizers = [];
$valueTypeNormalizers = [];
try {
Method factory
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function factory( $language, $sourceLanguage = null ) {
if ( is_string( $language ) ) {
$languageCode = self::validateLanguageCode( $language );
} else {
$languageCode = $language->getCode();
Identical blocks of code found in 2 locations. Consider refactoring. Open
function getRankName( rank ) {
for ( var rankName in datamodel.Statement.RANK ) {
if ( rank === datamodel.Statement.RANK[ rankName ] ) {
return rankName.toLowerCase();
}
- 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 61.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
_getRankName: function ( rank ) {
for ( var rankName in datamodel.Statement.RANK ) {
if ( rank === datamodel.Statement.RANK[ rankName ] ) {
return rankName.toLowerCase();
}
- 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 61.
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
Function _createEntitytermsforlanguagelistviewToggler
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
_createEntitytermsforlanguagelistviewToggler: function () {
this._registerTogglerForLanguagelistviewDiv( TOGGLER_OPTION_KEY );
this.$entitytermsforlanguagelistviewContainer.before(
this.$entitytermsforlanguagelistviewToggler
Function e260
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var toIndexedObject = __webpack_require__("fc6a");
Method getChangeParamsForDiffOp
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getChangeParamsForDiffOp( DiffOp $diffOp, $siteId, $messagePrefix ) {
$params = [];
if ( $diffOp instanceof DiffOpAdd ) {
$params['message'] = $messagePrefix . 'add';
Method showForm
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function showForm() {
$dataTypeSelect = new DataTypeSelector(
$this->dataTypeFactory->getTypes(),
$this->getLanguage()->getCode()
);
Method getChangeOp
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getChangeOp( array $preparedParameters, EntityDocument $entity ): ChangeOp {
if ( $this->shouldRemove( $preparedParameters ) ) {
$linksite = $this->stringNormalizer->trimToNFC( $preparedParameters['linksite'] );
return $this->siteLinkChangeOpFactory->newRemoveSiteLinkOp( $linksite );
} else {
Method modifyEntity
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function modifyEntity( EntityDocument $entity, ChangeOp $changeOp, array $preparedParameters ): Summary {
if ( !( $entity instanceof Item ) ) {
$this->errorReporter->dieError( "The given entity is not an item", "not-item" );
}
Method getSecondaryDataUpdates
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getSecondaryDataUpdates(
Title $title,
Content $content,
$role,
SlotRenderingProvider $slotOutput
Method getRegexpsFromMessageText
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getRegexpsFromMessageText( string $msgText ): array {
static $pluralRegex = null;
if ( $pluralRegex === null ) {
// We need to match on a preg_quoted string here, so double quote
$pluralRegex = '@' . preg_quote( preg_quote( '{{PLURAL:$1|' ) ) .
Method getTimeParsers
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getTimeParsers() {
global $wgDefaultUserOptions;
$eraParser = new MwEraParser( $this->options );
$isoTimestampParser = new IsoTimestampParser(
Method handleLabelsValidationError
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function handleLabelsValidationError( ValidationError $validationError ): void {
$context = $validationError->getContext();
switch ( $validationError->getCode() ) {
case LabelsSyntaxValidator::CODE_LABELS_NOT_ASSOCIATIVE:
Method formatSnak
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function formatSnak( Snak $snak ) {
$warningText = '';
try {
return $this->snakFormatter->formatSnak( $snak );
} catch ( MismatchingDataValueTypeException $ex ) {