File SpecialUpload.php
has 811 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Implements Special:Upload
*
* This program is free software; you can redistribute it and/or modify
Function showUploadWarning
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
protected function showUploadWarning( $warnings ) {
# If there are no warnings, or warnings we can ignore, return early.
# mDestWarningAck is set when some javascript has shown the warning
# to the user. mForReUpload is set when the user clicks the "upload a
# new version" link.
- 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 showUploadWarning
has 89 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function showUploadWarning( $warnings ) {
# If there are no warnings, or warnings we can ignore, return early.
# mDestWarningAck is set when some javascript has shown the warning
# to the user. mForReUpload is set when the user clicks the "upload a
# new version" link.
Method showUploadStatus
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function showUploadStatus( $user ) {
// first, let's fetch the status from the main stash
$progress = UploadBase::getSessionStatus( $user, $this->mCacheKey );
if ( !$progress ) {
$progress = [ 'status' => Status::newFatal( 'invalid-cache-key' ) ];
Function showUploadStatus
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
protected function showUploadStatus( $user ) {
// first, let's fetch the status from the main stash
$progress = UploadBase::getSessionStatus( $user, $this->mCacheKey );
if ( !$progress ) {
$progress = [ 'status' => Status::newFatal( 'invalid-cache-key' ) ];
- 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
SpecialUpload
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class SpecialUpload extends SpecialPage {
private LocalRepo $localRepo;
private UserOptionsLookup $userOptionsLookup;
private NamespaceInfo $nsInfo;
Method processVerificationError
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function processVerificationError( $details ) {
switch ( $details['status'] ) {
/** Statuses that only require name changing */
case UploadBase::MIN_LENGTH_PARTNAME:
$this->showRecoverableUploadError( $this->msg( 'minlength1' )->escaped() );
Method execute
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function execute( $par ) {
$this->useTransactionalTimeLimit();
$this->setHeaders();
$this->outputHeader();
Function processVerificationError
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
protected function processVerificationError( $details ) {
switch ( $details['status'] ) {
/** Statuses that only require name changing */
case UploadBase::MIN_LENGTH_PARTNAME:
$this->showRecoverableUploadError( $this->msg( 'minlength1' )->escaped() );
- 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 getUploadForm
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function getUploadForm( $message = '', $sessionKey = '', $hideIgnoreWarning = false ) {
# Initialize form
$form = new UploadForm(
[
'watch' => $this->getWatchCheck(),
Method showUploadProgress
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function showUploadProgress( $options ) {
// $isActive = $options['active'] ?? false;
//$progressBarProperty = $isActive ? '' : 'disabled';
$message = $this->msg( $options['msg'] )->escaped();
$destUrl = $this->mRequest->getText( 'wpDestUrl', '' );
Function execute
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function execute( $par ) {
$this->useTransactionalTimeLimit();
$this->setHeaders();
$this->outputHeader();
- 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 processAsyncUpload
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function processAsyncUpload() {
// Ensure the upload we're dealing with is an UploadFromUrl
if ( !$this->mUpload instanceof \UploadFromUrl ) {
$this->showUploadError( $this->msg( 'uploaderror' )->escaped() );
Method loadRequest
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function loadRequest() {
$this->mRequest = $request = $this->getRequest();
$this->mSourceType = $request->getVal( 'wpSourceType', 'file' );
$this->mUpload = UploadBase::createFromRequest( $request );
$this->mUploadClicked = $request->wasPosted()
Method performUploadChecks
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function performUploadChecks( $fetchFileStatus ): bool {
if ( !$fetchFileStatus->isOK() ) {
$this->showUploadError( $this->getOutput()->parseAsInterface(
$fetchFileStatus->getWikiText( false, false, $this->getLanguage() )
) );
Method getInitialPageText
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function getInitialPageText( $comment = '', $license = '',
$copyStatus = '', $source = '', Config $config = null
) {
if ( $config === null ) {
wfDebug( __METHOD__ . ' called without a Config instance passed to it' );
Method processUpload
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function processUpload() {
// Fetch the file if required
$status = $this->mUpload->fetchFile();
if ( !$this->performUploadChecks( $status ) ) {
return;
Function loadRequest
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function loadRequest() {
$this->mRequest = $request = $this->getRequest();
$this->mSourceType = $request->getVal( 'wpSourceType', 'file' );
$this->mUpload = UploadBase::createFromRequest( $request );
$this->mUploadClicked = $request->wasPosted()
- 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 getInitialPageText
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function getInitialPageText( $comment = '', $license = '',
$copyStatus = '', $source = '', Config $config = null
) {
if ( $config === null ) {
wfDebug( __METHOD__ . ' called without a Config instance passed to it' );
- 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 showUploadProgress
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function showUploadProgress( $options ) {
// $isActive = $options['active'] ?? false;
//$progressBarProperty = $isActive ? '' : 'disabled';
$message = $this->msg( $options['msg'] )->escaped();
$destUrl = $this->mRequest->getText( 'wpDestUrl', '' );
- 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 performUploadChecks
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function performUploadChecks( $fetchFileStatus ): bool {
if ( !$fetchFileStatus->isOK() ) {
$this->showUploadError( $this->getOutput()->parseAsInterface(
$fetchFileStatus->getWikiText( false, false, $this->getLanguage() )
) );
- 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 getPageTextAndTags
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
protected function getPageTextAndTags() {
// Get the page text if this is not a reupload
if ( !$this->mForReUpload ) {
$pageText = self::getInitialPageText( $this->mComment, $this->mLicense,
$this->mCopyrightStatus, $this->mCopyrightSource,
- 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 getInitialPageText
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function getInitialPageText( $comment = '', $license = '',
$copyStatus = '', $source = '', Config $config = null
Function getExistsWarning
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function getExistsWarning( $exists ) {
if ( !$exists ) {
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"
Further reading
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return false;
Function getWatchCheck
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function getWatchCheck() {
$user = $this->getUser();
if ( $this->userOptionsLookup->getBoolOption( $user, 'watchdefault' ) ) {
// Watch all edits!
return true;
- 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"