Showing 1,238 of 1,238 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
} else {
y1 = alignPixel(chart, me.top, firstLineWidth) - firstLineWidth / 2;
y2 = alignPixel(chart, me.bottom, lastLineWidth) + lastLineWidth / 2;
x1 = x2 = borderValue;
}
- 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 64.
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 showTranslation
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function showTranslation( translation ) {
var $target = $( '.translations' ),
translationLang = translation.title.split( '/' ).pop();
$target.append( $( '<div>' )
Function toggleSubscription
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function toggleSubscription() {
var api = new mw.Api();
var $button = $( this );
$button.prop( 'disabled', true );
Method __construct
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct() {
parent::__construct();
$this->addDescription( 'Review and move translatable bundles including their subpages' );
$this->addArg(
Method classifyPages
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function classifyPages( array $pages ): array {
$out = [
// The ideal state for pages: marked and up to date
'active' => [],
'proposed' => [],
Function _drawTitle
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
_drawTitle: function() {
var me = this;
var ctx = me.ctx;
var options = me.options;
var scaleLabel = options.scaleLabel;
Function decodeFill
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function decodeFill(el, index, count) {
var model = el._model || {};
var fill = model.fill;
var target;
Function _drawLabels
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
_drawLabels: function() {
var me = this;
var ctx = me.ctx;
var opts = me.options;
var tickOpts = opts.ticks;
Function render
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
render: function(config) {
var me = this;
if (!config || typeof config !== 'object') {
// backwards compatibility
Method move
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function move(
TranslatableBundle $sourceBundle,
User $performer,
array $pagesToMove,
array $pagesToRedirect,
Method handlePriorityLanguages
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function handlePriorityLanguages(
TranslatablePage $page,
TranslatablePageSettings $pageSettings,
UserIdentity $user
): void {
Method deleteUser
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function deleteUser( User $user, string $force = '' ): void {
$uid = $user->getId();
$actorId = $user->getActorId();
if ( $force !== 'force' && !self::isSandboxed( $user ) ) {
Method getWritable
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getWritable(): array {
$writableServers = $readOnlyServers = [];
$ttmServerIds = $this->getNames();
foreach ( $ttmServerIds as $serverId ) {
Method createSearch
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function createSearch( string $queryString, array $opts, array $highlight ): Search {
$query = new Query();
[ $searchQuery, $highlights ] = $this->parseQueryString( $queryString, $opts );
$query->setQuery( $searchQuery );
Method addUser
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addUser( string $name, string $email, string $password ): User {
$user = $this->userFactory->newFromName( $name, UserFactory::RIGOR_CREATABLE );
if ( !$user ) {
throw new InvalidArgumentException( 'Invalid user name' );
Method getHtmlForGroupErrors
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getHtmlForGroupErrors(
GroupSynchronizationResponse $groupErrorResponse,
Language $language,
string $wrapperClass
): string {
Method save
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function save(
Title $pageTitle,
RevisionRecord $revisionRecord,
MessageBundleContent $content
): void {
Method getMessages
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getMessages(): array {
if ( $this->messages !== null ) {
return $this->messages;
}
Method getTable
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getTable( array $stats ): string {
$table = $this->table;
$out = '';
// This avoids a database query per translatable page, which would be caused by
Method getGroupLoaders
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getGroupLoaders(): array {
if ( $this->groupLoaders !== null ) {
return $this->groupLoaders;
}