Showing 183 of 183 total issues
Method domParseMobile
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function domParseMobile( OutputPage $out, $html = '' ) {
$services = MediaWikiServices::getInstance();
/** @var FeaturesManager $featuresManager */
$featuresManager = $services->getService( 'MobileFrontend.FeaturesManager' );
/** @var MobileContext $context */
Function editorLoadingOverlay
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function editorLoadingOverlay( afterShow, afterHide, loadBasicEditor ) {
let timeout;
const
$fakeToolbar = fakeToolbar(),
$loadBasicWrapper = $( '<div>' ).addClass( 've-loadbasiceditor' ),
Method detectMobileDevice
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function detectMobileDevice( $userAgent ) {
$patterns = [
'mobi',
'240x240',
'240x320',
Similar blocks of code found in 2 locations. Consider refactoring. Open
$layout = new OOUI\FieldLayout(
$amcToggle,
[
'label' => new OOUI\LabelWidget( [
'input' => $amcToggle,
- 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 130.
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
$userPreferences = new OOUI\FieldLayout(
$spacer,
[
'label' => new OOUI\LabelWidget( [
'input' => $spacer,
- 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 130.
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 postRender
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
postRender: function () {
let
$img;
const
$el = this.$el,
Function template
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
get template() {
return util.template( `
<div class="block-message block-message-container">
<div class="block-message-icon"></div>
<div class="block-message-info">
Function getStructuredLanguages
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
getStructuredLanguages: function (
languages,
variants,
frequentlyUsedLanguages,
showSuggestedLanguages,
Function getContent
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
getContent: function () {
let options;
const self = this;
Method executeViewEditWatchlist
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function executeViewEditWatchlist() {
$ns = NS_MAIN;
$images = [];
$watchlist = $this->getWatchlistInfo();
Function parseBlockInfo
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function parseBlockInfo( blockinfo ) {
const blockInfo = {
partial: blockinfo.blockpartial || false,
noCreateAccount: blockinfo.blocknocreate || false,
anonOnly: blockinfo.blockanononly === undefined ? true : blockinfo.blockanononly,
Function amcOutreachDrawer
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function amcOutreachDrawer(
action,
promoCampaign,
mwMessage,
mwUtil,
Method submitSettingsForm
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function submitSettingsForm() {
$request = $this->getRequest();
$user = $this->getUser();
if ( $user->isRegistered() && !$user->matchEditToken( $request->getVal( 'token' ) ) ) {
Method doRewriteImagesForLazyLoading
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function doRewriteImagesForLazyLoading( $el, ?DOMDocument $doc ) {
if ( $doc === null ) {
return;
}
$lazyLoadSkipSmallImages = $this->skipSmall;
Function referenceDrawer
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
function referenceDrawer( props ) {
const errorIcon = props.error ? new IconButton( {
name: 'error',
isSmall: true
} ).$el : null;
Function createAnonWarning
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
createAnonWarning: function ( options ) {
const $actions = $( '<div>' ).addClass( 'actions' ),
// Use MediaWiki ResourceLoader require(), not Webpack require()
contLangMessages = (
Function onBeforePageDisplay
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function onBeforePageDisplay( $out, $skin ): void {
$context = $this->mobileContext;
$mfEnableXAnalyticsLogging = $this->config->get( 'MFEnableXAnalyticsLogging' );
$mfNoIndexPages = $this->config->get( 'MFNoindexPages' );
$isCanonicalLinkHandledByCore = $this->config->get( 'EnableCanonicalServerLink' );
- 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 findChildInSectionLead
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
findChildInSectionLead( sectionIndex, selector ) {
let $heading, $nextHeading;
const headingSelector = HEADING_SELECTOR;
- 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 getTopHeadings
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function getTopHeadings( DOMElement $doc ): array {
$headings = [];
foreach ( $this->topHeadingTags as $tagName ) {
$allTags = DOMCompat::querySelectorAll( $doc, $tagName );
- 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 _switchToVisualEditor
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
_switchToVisualEditor: function ( wikitext ) {
const self = this;
this.log( {
action: 'abort',
type: 'switchnochange',