wikimedia/mediawiki-extensions-WikiLove

View on GitHub

Showing 30 of 81 total issues

Method saveInDb has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function saveInDb( $talk, $subject, $message, $type, $email ) {
        $dbw = $this->dbProvider->getPrimaryDatabase();
        $receiver = User::newFromName( $talk->getSubjectPage()->getBaseText() );
        if ( $receiver === false || $receiver->isAnon() || $receiver->isTemp() ) {
            $this->addWarning( 'apiwarn-wikilove-ignoringunregistered' );
Severity: Minor
Found in includes/ApiWikiLove.php - About 1 hr to fix

    Function execute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function execute() {
            $params = $this->extractRequestParams();
    
            // In some cases we need the wiki mark-up stripped from the subject
            $strippedSubject = $this->parserFactory->getInstance()->stripSectionName( $params['subject'] );
    Severity: Minor
    Found in includes/ApiWikiLove.php - About 1 hr to fix

    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 submitSend has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        submitSend: function ( e ) {
            e.preventDefault();
            $( '#mw-wikilove-success' ).hide();
            $( '#mw-wikilove-dialog' ).find( '.mw-wikilove-error' ).remove();
    
    
    Severity: Minor
    Found in resources/ext.wikiLove.startup/wikiLove.js - About 1 hr to fix

    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 getUserTalkPage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function getUserTalkPage( PermissionManager $permissionManager, $title, $user ) {
            // Exit early if the sending user isn't logged in
            if ( !$user->isRegistered() || $user->isTemp() ) {
                return ApiMessage::create( 'wikilove-err-not-logged-in', 'notloggedin' );
            }
    Severity: Minor
    Found in includes/Hooks.php - About 55 mins to fix

    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 doSend has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        doSend: function ( subject, wikitext, message, type, email, extraTags ) {
    Severity: Minor
    Found in resources/ext.wikiLove.startup/wikiLove.js - About 45 mins to fix

      Method saveInDb has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          private function saveInDb( $talk, $subject, $message, $type, $email ) {
      Severity: Minor
      Found in includes/ApiWikiLove.php - About 35 mins to fix

        Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                ApiMain $main,
                $action,
                IConnectionProvider $dbProvider,
                ParserFactory $parserFactory,
                PermissionManager $permissionManager
        Severity: Minor
        Found in includes/ApiWikiLove.php - About 35 mins to fix

          Avoid too many return statements within this method.
          Open

                  return $talkTitle;
          Severity: Major
          Found in includes/Hooks.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return ApiMessage::create( 'wikilove-err-cannot-edit', 'cannotedit' );
            Severity: Major
            Found in includes/Hooks.php - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return true;
              Severity: Major
              Found in resources/ext.wikiLove.startup/wikiLove.js - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language