Showing 183 of 183 total issues
Function onEditLinkClick
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function onEditLinkClick( elem, ev, router ) {
let section;
if ( $( EDITSECTION_SELECTOR ).length === 0 ) {
// If section edit links are not available, the only edit link
// should allow editing the whole page (T232170)
- 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 scrollToLeadParagraph
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
scrollToLeadParagraph: function () {
let editLead, editLeadView, readLead, offset, initialCursorOffset;
const
currentPageHTMLParser = this.options.currentPageHTMLParser,
- 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 domParseMobile
has a Cognitive Complexity of 10 (exceeds 5 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 */
- 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 delegateEvents
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
delegateEvents( events ) {
let match, key, method;
events = events || this.options.events;
if ( events ) {
// Remove current events before re-binding them
- 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 parseBlockInfo
has a Cognitive Complexity of 10 (exceeds 5 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,
- 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 submitSettingsForm
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function submitSettingsForm() {
$request = $this->getRequest();
$user = $this->getUser();
if ( $user->isRegistered() && !$user->matchEditToken( $request->getVal( 'token' ) ) ) {
- 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
Method getUserPageContent
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected static function getUserPageContent( IContextSource $output,
User $pageUser, Title $title
) {
/** @var MobileContext $context */
$context = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Context' );
Method isSupportedEditRequest
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected static function isSupportedEditRequest( IContextSource $context ) {
/** @var MobileContext $mobileContext */
$mobileContext = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Context' );
if ( !$mobileContext->shouldDisplayMobileView() ) {
return false;
Function scrollToLeadParagraph
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
scrollToLeadParagraph: function () {
let editLead, editLeadView, readLead, offset, initialCursorOffset;
const
currentPageHTMLParser = this.options.currentPageHTMLParser,
Function getButtonConfig
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
getButtonConfig() {
let cta = true;
const config = {
progressive: true
},
Method identifyInfoboxElement
has 27 lines of code (exceeds 25 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)
Method onCustomEditor
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function onCustomEditor( $article, $user ) {
$req = $article->getContext()->getRequest();
$title = $article->getTitle();
if (
!$req->getVal( 'mfnoscript' ) &&
Function bindEditLinksLoginDrawer
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function bindEditLinksLoginDrawer( router ) {
let drawer;
function showLoginDrawer() {
if ( !drawer ) {
drawer = new CtaDrawer( {
Method shouldDisplayMobileViewInternal
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function shouldDisplayMobileViewInternal() {
// May be overridden programmatically
if ( $this->forceMobileView ) {
return true;
}
Function getLicenseMsg
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
getLicenseMsg() {
const $licenseLinks = this.getLicenseLinks();
let licenseMsg;
if ( $licenseLinks.length ) {
Method __construct
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
HookContainer $hookContainer,
Config $config,
SkinFactory $skinFactory,
UserOptionsLookup $userOptionsLookup,
WatchlistManager $watchlistManager,
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ( mw.user.isAnon() ) {
mw.user.clientPrefs.set( FONT_SIZE_KEY, 'large' );
} else {
api.saveOption( FONT_SIZE_KEY, 'large' );
}
- 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 54.
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
if ( mw.user.isAnon() ) {
mw.user.clientPrefs.set( SECTION_COLLAPSING_TOGGLE, '1' );
} else {
api.saveOption( SECTION_COLLAPSING_TOGGLE, '1' );
}
- 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 54.
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 exports
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
module.exports = function () {
const
currentPage = require( '../mobile.startup/currentPage' )(),
Toggler = require( '../mobile.startup/Toggler' ),
sectionCollapsing = require( '../mobile.startup/sectionCollapsing' ),
- 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 makeSections
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function makeSections( DOMElement $body, array $headingWrappers ) {
$ownerDocument = $body->ownerDocument;
if ( $ownerDocument === null ) {
return;
}
- 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"