Showing 1,238 of 1,238 total issues
Method execute
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
$this->bundleMover = Services::getInstance()->getTranslatableBundleMover();
$mwService = MediaWikiServices::getInstance();
$this->titleParser = $mwService->getTitleParser();
Method onSaveComplete
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function onSaveComplete(
WikiPage $wikiPage,
UserIdentity $userIdentity,
string $summary,
int $flags,
Method execute
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
$params = $this->extractRequestParams();
$title = Title::newFromText( $params['title'] );
if ( !$title ) {
Function addMessage
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
function addMessage( message ) {
var $messageTable = $( '.tux-messagelist' ),
sourceLanguage = $messageTable.data( 'sourcelangcode' ),
sourceLanguageDir = $.uls.data.getDir( sourceLanguage ),
targetLanguage = $messageTable.data( 'targetlangcode' ),
Function addExpanders
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
function addExpanders( $table ) {
var $metaRows = $( 'tr.AggregateMessageGroup', $table );
// Quick return
if ( !$metaRows.length ) {
Method actionLinks
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function actionLinks( array $page, string $type ): string {
// Performance optimization to avoid calling $this->msg in a loop
static $messageCache = null;
if ( $messageCache === null ) {
$messageCache = [
Method getPageMoveCollection
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getPageMoveCollection(
Title $source,
?Title $target,
User $user,
string $reason,
Method parseFile
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function parseFile(): array {
$defines = file_get_contents( $this->definitionFile );
$linefeed = '(\r\n|\n)';
$sections = array_map(
'trim',
Method sendNotifications
has 71 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sendNotifications( array $changesToProcess ): void {
if ( !$this->isEnabled() || $changesToProcess === [] ) {
return;
}
MessageBundleMessageGroup
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class MessageBundleMessageGroup implements MessageGroup {
/** Name of the bundle (prefixed text of the bundle page) */
private string $name;
private string $groupId;
private int $pageId;
Similar blocks of code found in 2 locations. Consider refactoring. Open
$specialPageAliases['lb'] = [
'ImportTranslations' => [ 'Iwwersetzungen_importéieren' ],
'LanguageStats' => [ 'Sproochestatistiken' ],
'ManageMessageGroups' => [ 'Gruppe_vu_Message_geréieren' ],
'ManageTranslatorSandbox' => [ 'Iwwersetzungssandkëscht_geréieren' ],
- 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 138.
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
$specialPageAliases['bgn'] = [
'AggregateGroups' => [ 'گروپ_ئآنی_جم' ],
'ImportTranslations' => [ 'ترجمه_ئانی_درون_بررّگ' ],
'LanguageStats' => [ 'زبان_ئانی_سرجم' ],
'ManageMessageGroups' => [ 'پیامی_گروپ_ئانی_مدیریت' ],
- 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 138.
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 splineCurveMonotone
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
helpers$1.splineCurveMonotone = function(points) {
// This function calculates Bézier control points in a similar way than |splineCurve|,
// but preserves monotonicity of the provided data and ensures no local extremums are added
// between the dataset discrete points due to the interpolation.
// See : https://en.wikipedia.org/wiki/Monotone_cubic_interpolation
Method formatGroup
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function formatGroup( $mixed, array $props, int $depth = 0 ): array {
$params = $this->extractRequestParams();
$context = $this->getContext();
// Default
File MessageSourceChange.php
has 282 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Contains a class to track changes to the messages when importing messages from remote source.
* @author Abijeet Patro
* @license GPL-2.0-or-later
Function save
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
save: function () {
var translateEditor = this;
mw.hook( 'mw.translate.editor.beforeSubmit' ).fire( translateEditor.$editor );
var translation = translateEditor.$editor.find( '.tux-textarea-translation' ).val();
Function showData
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
function showData( apiResponse, options ) {
var graphData = getAxesLabelsAndData( apiResponse.data ),
graphDatasets = [],
datasetLabels = apiResponse.labels;
Method createMessageGroup
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function createMessageGroup( string $id, array $info ): MessageGroup {
$conf = [];
$conf['BASIC']['class'] = MediaWikiExtensionMessageGroup::class;
$conf['BASIC']['id'] = $id;
$conf['BASIC']['namespace'] = $this->getNamespace();
Function execute
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function execute() {
global $wgSitename, $wgTranslateMessageNamespaces;
$days = (int)$this->getOption( 'days', 30 );
$top = (int)$this->getOption( 'top', -1 );
- 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 20 (exceeds 5 allowed). Consider refactoring. Open
public function execute() {
global $wgTranslateMessageNamespaces;
$namespace = $this->getOption( 'namespace', $wgTranslateMessageNamespaces );
$nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
- 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"