File ext.translate.special.pagemigration.js
has 378 lines of code (exceeds 250 allowed). Consider refactoring. Open
( function () {
'use strict';
var noOfSourceUnits, noOfTranslationUnits,
pageName = '',
langCode = '',
Function importHandler
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
function importHandler( e ) {
var $errorBox = $( '.mw-tpm-sp-error__message' ),
$messageBox = $( '.mw-tpm-sp-instructions' );
e.preventDefault();
Function alignHeaders
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function alignHeaders( units, translationUnits ) {
// The content does not have information about the page title. Add an empty string
// at the beginning of the translationUnits array to match the length of units and
// translationUnits.
if ( units.length && units[ 0 ].identifier === 'Page_display_title' ) {
Function getSourceUnits
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getSourceUnits( page ) {
var api = new mw.Api();
return api.get( {
action: 'query',
Function getFuzzyTimestamp
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getFuzzyTimestamp( pageTitle ) {
var api = new mw.Api();
// This api call returns the timestamp of FuzzyBot's edit
return api.get( {
Function createNewUnit
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function createNewUnit( sourceText, targetText ) {
var $newUnit = $( '<div>' ).addClass( 'mw-tpm-sp-unit row' );
var $sourceUnit = $( '<textarea>' ).addClass( 'mw-tpm-sp-unit__source five columns' )
.prop( 'readonly', true ).attr( 'tabindex', '-1' ).val( sourceText );
var $target = $( '<div>' ).addClass( 'five columns' );
Function saveHandler
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function saveHandler() {
var list = [];
$( '.mw-tpm-sp-error__message' ).addClass( 'hide' );
if ( noOfSourceUnits < noOfTranslationUnits ) {
Avoid deeply nested control flow statements. Open
if ( i !== 0 ) {
translationUnits[ i - 1 ] += '\n' + mergeText;
} else {
matchText = mergeText + matchText;
}
Avoid deeply nested control flow statements. Open
while ( emptyCount !== 0 ) {
mergeText += translationUnits.splice( i, 1 ).toString() + '\n';
emptyCount += 1;
}
Similar blocks of code found in 3 locations. Consider refactoring. Open
if ( obj === undefined || obj.missing === '' ) {
$errorBox.text( mw.msg( 'pm-page-does-not-exist', pageTitle ) ).removeClass( 'hide' );
return $.Deferred().reject();
}
- 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 49.
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 3 locations. Consider refactoring. Open
if ( obj.revisions === undefined ) {
$errorBox.text( mw.msg( 'pm-old-translations-missing', pageTitle ) ).removeClass( 'hide' );
return $.Deferred().reject();
} else {
// FB over here refers to FuzzyBot
- 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 49.
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 3 locations. Consider refactoring. Open
if ( obj === undefined || obj.missing ) {
$errorBox.text( mw.msg( 'pm-page-does-not-exist', pageTitle ) ).removeClass( 'hide' );
return $.Deferred().reject();
}
- 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 49.
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