Showing 11,545 of 11,545 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
calendar: {
sameDay: '[dnes v] LT',
nextDay: '[zítra v] LT',
nextWeek: function () {
switch (this.day()) {
- 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 157.
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 setup
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
setup(props, { emit }) {
const labelId = useGeneratedId("dialog-label");
const backdrop = ref();
const dialogElement = ref();
const dialogBody = ref();
- 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 buildContent
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
final protected function buildContent( Context $context ) {
$statsFactory = MediaWikiServices::getInstance()->getStatsFactory();
$statStart = microtime( true );
// This MUST build both scripts and styles, regardless of whether $context->getOnly()
- 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 mergeFieldInfo
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
public static function mergeFieldInfo( array $reqs ) {
$merged = [];
// fields that are required by some primary providers but not others are not actually required
$sharedRequiredPrimaryFields = 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 loadUnguarded
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
private function loadUnguarded( $code, $mode ) {
$success = false; // Keep track of success
$staleCache = false; // a cache array with expired data, or false if none has been loaded
$where = []; // Debug info, delayed to avoid spamming debug log too much
- 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 getFieldDefinitions
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
protected function getFieldDefinitions( array $fieldInfo ) {
$isLoggedIn = $this->getUser()->isRegistered();
$continuePart = $this->isContinued() ? 'continue-' : '';
$anotherPart = $isLoggedIn ? 'another-' : '';
// @phan-suppress-next-line PhanUndeclaredMethod
- 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 getCurrentUserInfo
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
protected function getCurrentUserInfo() {
$user = $this->getUser();
$vals = [];
$vals['id'] = $user->getId();
$vals['name'] = $user->getName();
- 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 parseParameters
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
protected function parseParameters( $params ) {
$prop = array_fill_keys( $params['prop'], true );
$this->fld_ids = isset( $prop['ids'] );
$this->fld_flags = isset( $prop['flags'] );
- 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 setVals
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
private function setVals( &$vals, $prefix, $rev ) {
if ( $rev ) {
$title = Title::newFromLinkTarget( $rev->getPageAsLinkTarget() );
if ( isset( $this->props['ids'] ) ) {
$vals["{$prefix}id"] = $title->getArticleID();
- 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 executeInternal
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
private function executeInternal( $isDryRun ) {
$generatorName = $this->mAllowGenerator ? $this->mParams['generator'] : null;
if ( isset( $generatorName ) ) {
$dbSource = $this->mDbSource;
if ( !$dbSource instanceof ApiQuery ) {
- 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 getNearMatchInternal
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
protected function getNearMatchInternal( $searchterm ) {
$allSearchTerms = [ $searchterm ];
if ( $this->languageConverter->hasVariants() ) {
$allSearchTerms = array_unique( array_merge(
- 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 execute
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
public function execute() {
# Change to current working directory
$oldCwd = getcwd();
chdir( $oldCwd );
- 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 main
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
public function main() {
$services = $this->getServiceContainer();
$contLang = $services->getContentLanguage();
$langConverter = $services->getLanguageConverterFactory()->getLanguageConverter( $contLang );
$serverUrl = $services->getUrlUtils()->getServer( PROTO_CANONICAL ) ?? '';
- 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
Method getChunkResult
has 152 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getChunkResult( $warnings ) {
$result = [];
if ( $warnings && count( $warnings ) > 0 ) {
$result['warnings'] = $warnings;
Method showResults
has 152 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function showResults( $term ) {
if ( $this->searchEngineType !== null ) {
$this->setExtraParam( 'srbackend', $this->searchEngineType );
}
File categoryChangesAsRdf.php
has 418 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
ApiHookRunner
has 44 functions (exceeds 20 allowed). Consider refactoring. Open
class ApiHookRunner implements
Hook\APIAfterExecuteHook,
Hook\ApiCheckCanExecuteHook,
Hook\ApiDeprecationHelpHook,
Hook\ApiLogFeatureUsageHook,
Linker
has 44 functions (exceeds 20 allowed). Consider refactoring. Open
class Linker {
/**
* Flags for userToolLinks()
*/
public const TOOL_LINKS_NOBLOCK = 1;
SearchEngine
has 44 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class SearchEngine {
public const DEFAULT_SORT = 'relevance';
/** @var string */
public $prefix = '';
Similar blocks of code found in 2 locations. Consider refactoring. Open
_ctx.highlightQuery ? (openBlock(), createBlock(_component_cdx_search_result_title, {
key: 0,
title: _ctx.match,
"search-query": _ctx.searchQuery,
lang: (_c = _ctx.language) == null ? void 0 : _c.match
- 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 155.
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