Showing 183 of 183 total issues
Function exports
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function () {
const
currentPage = require( '../mobile.startup/currentPage' )(),
Toggler = require( '../mobile.startup/Toggler' ),
sectionCollapsing = require( '../mobile.startup/sectionCollapsing' ),
Method makeSections
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function makeSections( DOMElement $body, array $headingWrappers ) {
$ownerDocument = $body->ownerDocument;
if ( $ownerDocument === null ) {
return;
}
Function showReference
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
showReference( id, page, refNumber, pageHTMLParser, gateway, props,
onShowNestedReference
) {
return gateway.getReference( id, page, pageHTMLParser ).then( ( reference ) => {
const drawer = referenceDrawer( util.extend( {
Function preRender
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
preRender: function () {
const options = this.options;
this.options.headers = [
headers.formHeader(
Function showLoading
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function showLoading() {
let $sectionTop, fakeScroll, enableVisualSectionEditing;
$( document.body ).addClass( 've-loading' );
Function getPreferredEditor
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function getPreferredEditor() {
if ( editorOverride ) {
// Temporary override, set via the URL for this request
// or by clicking the chosen mode when both tabs are shown
return editorOverride;
- 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 identifyInfoboxElement
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function identifyInfoboxElement( DOMXPath $xPath, DOMElement $section ): ?DOMElement {
$paths = [
// Infoboxes: *.infobox
'.//*[contains(concat(" ",normalize-space(@class)," ")," infobox ")]',
// Thumbnail images: .thumb, figure (Parsoid)
- 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 addSettingsForm
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function addSettingsForm() {
$out = $this->getOutput();
$user = $this->getUser();
$isTemp = $user->isTemp();
- 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 blockMessageDrawer
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function blockMessageDrawer( props ) {
const blockDrawer = new Drawer( {
className: 'drawer block-message',
onBeforeHide: function ( drawer ) {
drawer.$el.remove();
Function onStageChanges
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
onStageChanges: function () {
const self = this,
params = {
text: this.getContent()
};
Method moveFirstParagraphBeforeInfobox
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function moveFirstParagraphBeforeInfobox( DOMElement $leadSection, ?DOMDocument $doc ) {
if ( $doc === null ) {
return;
}
$xPath = new DOMXPath( $doc );
Method execute
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute() {
$services = MediaWikiServices::getInstance();
$urlUtils = $services->getUrlUtils();
$config = $this->getConfig();
Function loadImage
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function loadImage( placeholder ) {
const
deferred = util.Deferred(),
// data-width and height are attributes and do not specify dimension.
width = placeholder.dataset.width,
Method buildMobileUserPreferences
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function buildMobileUserPreferences() {
$spacer = new OOUI\LabelWidget( [
'name' => 'mobile_preference_spacer',
] );
$userPreferences = new OOUI\FieldLayout(
Method onOutputPageBeforeHTML
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function onOutputPageBeforeHTML( $out, &$text ) {
// This hook can be executed more than once per page view if the page content is composed from
// multiple sources! Anything that doesn't depend on $text should use onBeforePageDisplay.
$context = $this->mobileContext;
Function makeHeader
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function makeHeader( headingOrView, headerActions, headerCancel, additionalClassNames ) {
const heading = typeof headingOrView === 'string' ? headingOrView : undefined,
templateData = {
hasActions: headerActions && headerActions.length,
isHidden: false,
Function setupEditor
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function setupEditor( page, skin, currentPageHTMLParser, router ) {
const
overlayManager = OverlayManager.getSingleton(),
isNewPage = page.id === 0;
- 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 doToggling
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function doToggling() {
// make sure viewChange is set
$this->shouldDisplayMobileView();
if ( !$this->viewChange ) {
- 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 onRequestContextCreateSkin
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function onRequestContextCreateSkin( $context, &$skin ) {
$mobileContext = $this->mobileContext;
$mobileContext->doToggling();
if ( !$mobileContext->shouldDisplayMobileView() ) {
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
newOverlay.getLoadingPromise().then( function () {
self.switching = true;
self.overlayManager.replaceCurrent( newOverlay );
self.switching = false;
} );
- 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 60.
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