Showing 1,238 of 1,238 total issues
Similar blocks of code found in 4 locations. Consider refactoring. Open
$specialPageAliases['ml'] = [
'ImportTranslations' => [ 'പരിഭാഷാ_ഇറക്കുമതി' ],
'LanguageStats' => [ 'ഭാഷാസ്ഥിതിവിവരം' ],
'ManageMessageGroups' => [ 'സന്ദേശസംഘങ്ങളുടെകൈകാര്യം' ],
'MessageGroupStats' => [ 'സന്ദേശഗണസ്ഥിതിവിവരം' ],
- 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 102.
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 4 locations. Consider refactoring. Open
$specialPageAliases['ia'] = [
'ImportTranslations' => [ 'Importar_traductiones' ],
'LanguageStats' => [ 'Statisticas_de_linguas' ],
'ManageMessageGroups' => [ 'Gerer_gruppos_de_messages' ],
'MessageGroupStats' => [ 'Statisticas_de_gruppos_de_messages' ],
- 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 102.
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 updateElement
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateElement: function(point, index, reset) {
var me = this;
var custom = point.custom || {};
var dataset = me.getDataset();
var scale = me.chart.scale;
Function updateBezierControlPoints
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateBezierControlPoints: function() {
var me = this;
var meta = me.getMeta();
var area = me.chart.chartArea;
var points = meta.data || [];
Method execute
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
global $wgTranslateGroupFiles, $wgTranslateYamlLibrary;
$documents = [];
$times = [];
$mems = [];
Function drawLegendBox
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
var drawLegendBox = function(x, y, legendItem) {
if (isNaN(boxWidth) || boxWidth <= 0) {
return;
}
Method isSourcePage
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function isSourcePage( PageIdentity $page ): bool {
if ( !$page->exists() ) {
// No point in loading all translatable pages if the page
// doesn’t exist. This also avoids PreconditionExceptions
// if $page is a Title pointing to a non-proper page like
Method getDocumentationBox
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getDocumentationBox(): string {
global $wgTranslateDocumentationLanguageCode;
if ( !$wgTranslateDocumentationLanguageCode ) {
throw new TranslationHelperException( 'Message documentation language code is not defined' );
Method execute
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute( $parameters ) {
$out = $this->getOutput();
$out->addModuleStyles( [
'ext.translate.special.translate.styles',
'jquery.uls.grid',
Method onMovePageTranslationUnits
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function onMovePageTranslationUnits(
LinkTarget $oldLinkTarget,
LinkTarget $newLinkTarget,
UserIdentity $userIdentity,
int $oldid,
Method doReview
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function doReview( User $user, RevisionRecord $revRecord ): bool {
$dbw = $this->loadBalancer->getConnection( DB_PRIMARY );
$dbw->newInsertQueryBuilder()
->insertInto( 'translate_reviews' )
->ignore()
Method __construct
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct() {
parent::__construct();
$this->addDescription( 'Creates a dump file that can be imported to a TtmServer' );
$this->addOption(
Method formatWebSuggestions
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function formatWebSuggestions( array $queryData ): array {
$service = $queryData['service'];
$response = $queryData['response'];
$sourceLanguage = $queryData['language'];
$sourceText = $queryData['text'];
Method query
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function query( string $sourceLanguage, string $targetLanguage, string $text ): array {
// Calculate the bounds of the string length which are able
// to satisfy the cutoff percentage in edit distance.
$len = mb_strlen( $text );
$min = ceil( max( $len * $this->config['cutoff'], 2 ) );
Method getHopefullyValidConfigurations
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getHopefullyValidConfigurations( string $data, ?callable $callback = null ): array {
if ( !is_callable( $callback ) ) {
$callback = static function ( $unused1, $unused2, $unused3 ) {
/*noop*/
};
Method getGroupErrorInfo
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getGroupErrorInfo( string $groupId ): GroupSynchronizationResponse {
$groupMessageErrorTag = $this->getGroupMessageErrorTag( $groupId );
$groupMessageEntries = $this->cache->getByTag( $groupMessageErrorTag );
$groupErrorKey = $this->getGroupErrorKey( $groupId );
Method languageCloud
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function languageCloud(): array {
$cacheKey = $this->cache->makeKey( 'translate-supportedlanguages-language-cloud', 'v2' );
$data = $this->cache->get( $cacheKey );
if ( is_array( $data ) ) {
Method execute
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
$params = $this->extractRequestParams();
$target = $this->validateTargetParamater( $params );
$cache = $this->loadStatistics( $target, MessageGroupStats::FLAG_CACHE_ONLY );
Method getLanguagesFromHeader
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getLanguagesFromHeader( array $csvHeader ): Status {
if ( count( $csvHeader ) < 2 ) {
return Status::newFatal(
'CSV has < 2 columns. Assuming that there are no languages to import'
);
Method getAllowedParams
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getAllowedParams(): array {
return [
'do' => [
ParamValidator::PARAM_TYPE => [ 'associate', 'dissociate', 'remove', 'add', 'update' ],
ParamValidator::PARAM_REQUIRED => true,