Showing 436 of 912 total issues
Method transformWikitext
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
PageIdentity $page,
Bcp47Code $targetLanguage,
string $wikitext,
bool $bodyOnly,
?int $oldid,
Function getWikitext
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
ve.dm.MWTransclusionNode.static.getWikitext = function ( content ) {
let wikitext = '';
// Normalize to multi template format
if ( content.params ) {
- 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
Avoid deeply nested control flow statements. Open
Open
if ( section ) {
// switching from visual via the "add section" tab
target.switchToWikitextSection( section );
} else {
target.editSource();
Method onVisualEditorApiVisualEditorEditPreSave
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
ProperPageIdentity $page,
UserIdentity $user,
string $wikitext,
array &$params,
array $pluginData,
Method onVisualEditorApiVisualEditorEditPreSave
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
ProperPageIdentity $page,
UserIdentity $user,
string $wikitext,
array &$params,
array $pluginData,
Consider simplifying this complex logical expression. Open
Open
if (
(
( imageType === 'frameless' || imageType === 'none' ) &&
alignment === 'none'
) ||
Consider simplifying this complex logical expression. Open
Open
if ( attributeChanges.mw.from.parts.length === 1 && attributeChanges.mw.to.parts.length === 1 ) {
// Single-template transclusion, before and after. Relatively easy to summarize.
// TODO: expand this to well-represent transclusions that contain multiple templates.
// The bits of a template we care about are deeply-nested inside an
Consider simplifying this complex logical expression. Open
Open
if ( isVisual && !(
lastDiff && lastDiff.oldId === oldId && lastDiff.newId === newId &&
lastDiff.oldPageName === oldPageName && lastDiff.newPageName === newPageName
) ) {
$visualDiff.empty();
Consider simplifying this complex logical expression. Open
Open
if ( mode === 'traditional' || mode === 'nolines' || mode === 'slideshow' ) {
const imagePadding = ( mode === 'traditional' ? 30 : 0 );
innerDivWidth = parseInt( galleryMwAttrs.widths || defaults.imageWidth ) + imagePadding;
innerDivHeight = parseInt( galleryMwAttrs.heights || defaults.imageHeight ) + imagePadding;
if ( mode === 'traditional' ) {
Consider simplifying this complex logical expression. Open
Open
if (
// Modified click (e.g. ctrl+click)
!init.isUnmodifiedLeftClick( e ) ||
// Not an edit action
!( linkUrl.searchParams.has( 'action' ) || linkUrl.searchParams.has( 'veaction' ) ) ||
Consider simplifying this complex logical expression. Open
Open
if (
$config->get( 'VisualEditorUseSingleEditTab' ) &&
wfTimestampNow() < $config->get( 'VisualEditorSingleEditTabSwitchTimeEnd' ) &&
$user->isNamed() &&
self::enabledForUser( $user ) &&
Function toggleWrapSelection
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
ve.ui.MWWikitextAction.prototype.toggleWrapSelection = function ( before, after, placeholder, expandOffsetsCallback, unwrapOffsetsCallback ) {
Function runScreenshotTest
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
function runScreenshotTest( lang, name, clientScript, padding, teardownScript ) {
Function runMenuTask
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
runMenuTask: function ( done, tool, expanded, highlight, extraElements ) {
Method getHtmlInputTransformHelper
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
PageIdentity $page,
string $html,
int $oldid = null,
string $etag = null,
Bcp47Code $pageLanguage = null
Function getVisualDiffGeneratorPromise
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
getVisualDiffGeneratorPromise: function ( oldIdOrPromise, newIdOrPromise, parseDocumentModulePromise, oldPageName, newPageName ) {
Method transformHTML
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
PageIdentity $page, Bcp47Code $targetLanguage, string $html, ?int $oldid, ?string $etag
Method getHtmlOutputRendererHelper
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
PageIdentity $page,
?RevisionRecord $revision = null,
Bcp47Code $pageLanguage = null,
bool $stash = false,
string $flavor = self::FLAVOR_DEFAULT
Method onPreferencesFormPreSave
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
public function onPreferencesFormPreSave( $data, $form, $user, &$result, $oldUserOptions ) {
Method transformWikitext
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
Title $title, string $wikitext, bool $bodyOnly, int $oldid = null, bool $stash = false