Showing 2,096 of 2,096 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
'WikibaseRepo.DataTypeDefinitions' => function ( MediaWikiServices $services ): DataTypeDefinitions {
$baseDataTypes = require __DIR__ . '/../lib/WikibaseLib.datatypes.php';
$repoDataTypes = require __DIR__ . '/WikibaseRepo.datatypes.php';
$dataTypes = wfArrayPlus2d(
- 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 114.
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
'WikibaseClient.DataTypeDefinitions' => function ( MediaWikiServices $services ): DataTypeDefinitions {
$baseDataTypes = require __DIR__ . '/../lib/WikibaseLib.datatypes.php';
$clientDataTypes = require __DIR__ . '/WikibaseClient.datatypes.php';
$dataTypes = wfArrayPlus2d(
- 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 114.
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 _combineResults
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
_combineResults: function ( hookResults, searchResults ) {
var self = this,
deferred = $.Deferred(),
ids = {},
result = [],
Method showConfirmationForm
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function showConfirmationForm( int $autoSummaryLength, int $undidRevision = 0 ): void {
$req = $this->getRequest();
$args = [
'action' => 'submit',
Method switchForm
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function switchForm( ?string $languageCode, ?string $label ): void {
$formDescriptor = [
'language' => [
'name' => 'language',
'default' => $languageCode ?: '',
Method attemptSaveEntity
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function attemptSaveEntity(
EntityDocument $entity,
$summary,
array $requestParams,
IContextSource $context,
Method onSkinTemplateNavigationUniversal
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function onSkinTemplateNavigationUniversal( SkinTemplate $skinTemplate, array &$links ) {
$entityContentFactory = WikibaseRepo::getEntityContentFactory();
$title = $skinTemplate->getRelevantTitle();
Method execute
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
$newJsonName = $this->getOption( 'config' );
$newJson = json_decode( file_get_contents( $newJsonName ), true );
if ( !$newJson ) {
$this->fatalError( "Cannot load new config" );
Method handleSitelinksValidationError
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function handleSitelinksValidationError( ValidationError $validationError, array $sitelinksSerialization ): void {
$context = $validationError->getContext();
$siteId = fn() => $context[ SitelinkValidator::CONTEXT_SITE_ID ];
switch ( $validationError->getCode() ) {
case SitelinksValidator::CODE_INVALID_SITELINK:
Function apiErrorToPermissionError
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
private apiErrorToPermissionError( error: ApiError, semiProtectedLevels: readonly string[] ): PermissionError {
assertIsApiErrorRawErrorformat( error );
switch ( error.code ) {
case 'protectedpage': {
const right = error.params[ 0 ] as string;
Function ViewFactory
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
structureEditorFactory,
contentLanguages,
dataTypeStore,
entityIdHtmlFormatter,
entityIdPlainFormatter,
Method __construct
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
SiteLinkLookup $siteLinkLookup,
EntityIdLookup $entityIdLookup,
SettingsArray $settings,
UsageAccumulator $usageAccumulator,
EntityIdParser $entityIdParser,
Method __construct
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
EntityChangeFactory $entityChangeFactory,
EntityIdParser $entityIdParser,
EntityIdComposer $entityIdComposer,
EntityIdLookup $entityIdLookup,
EntityTitleStoreLookup $entityTitleLookup,
Method factory
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
AnonymousEditWarningBuilder $anonymousEditWarningBuilder,
MediaWikiEditEntityFactory $editEntityFactory,
EntityNamespaceLookup $entityNamespaceLookup,
EntityTitleLookup $entityTitleLookup,
FallbackLabelDescriptionLookupFactory $labelDescriptionLookupFactory,
Method __construct
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
ApiMain $mainModule,
string $moduleName,
LinkBatchFactory $linkBatchFactory,
EntitySearchHelper $entitySearchHelper,
ContentLanguages $termLanguages,
Method factory
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
ApiMain $mainModule,
string $moduleName,
LinkBatchFactory $linkBatchFactory,
ApiHelperFactory $apiHelperFactory,
array $enabledEntityTypes,
Method __construct
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
EntityExistenceChecker $entityExistenceChecker,
EntityIdParser $entityIdParser,
TermLookup $termLookup,
EntityNamespaceLookup $localEntityNamespaceLookup,
InterwikiLookup $interwikiLookup,
Method __construct
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
EntityTermStoreWriter $entityTermStoreWriter,
EntityContentDataCodec $contentCodec,
EntityConstraintProvider $constraintProvider,
ValidatorErrorLocalizer $errorLocalizer,
EntityIdParser $entityIdParser,
Function save
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
save: function ( statement ) {
var self = this,
deferred = $.Deferred();
this._api.setClaim(
Function _setOption
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
_setOption: function ( key, value ) {
var response = PARENT.prototype._setOption.apply( this, arguments );
if ( key === 'disabled' ) {
if ( this._mainSnakSnakView ) {