wikimedia/mediawiki-extensions-Translate

View on GitHub

Showing 1,238 of 1,238 total issues

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

    public function execute() {
        $handle = fopen( $this->getArg( 0 ), 'r' );
        // remove heading
        // @phan-suppress-next-line PhanPluginUseReturnValueInternalKnown
        fgets( $handle );
Severity: Minor
Found in scripts/translator-stats-process.php - About 4 hrs 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 onGetUserPermissionsErrorsExpensive has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    public static function onGetUserPermissionsErrorsExpensive(
        Title $title,
        User $user,
        $action,
        &$result
Severity: Minor
Found in src/PageTranslation/Hooks.php - About 4 hrs 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 execute has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute( $par ) {
        $request = $this->getRequest();

        $purge = $request->getVal( 'action' ) === 'purge';
        if ( $purge && !$request->wasPosted() ) {
Severity: Minor
Found in src/Statistics/MessageGroupStatsSpecialPage.php - About 4 hrs 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 execute has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    public function execute() {
        $config = $this->getConfig();
        $logger = LoggerFactory::getInstance( 'Translate.GroupSynchronization' );
        $groupPattern = $this->getOption( 'group' ) ?? '';
        $logger->info(
Severity: Minor
Found in src/Synchronization/BackportTranslationsMaintenanceScript.php - About 4 hrs 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 displayRequestDetails has 105 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function displayRequestDetails( request ) {
        var $reminderStatus = $( '<span>' ).addClass( 'reminder-status' ),
            $detailsPane = $( '.details.pane' );
        if ( request.reminderscount ) {
            var agoText = moment.isMoment( request.lastreminder ) ? moment( request.lastreminder ).fromNow() : request.lastreminder;
Severity: Major
Found in resources/js/ext.translate.special.managetranslatorsandbox.js - About 4 hrs to fix

    ElasticSearchTtmServer has 33 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ElasticSearchTtmServer
        extends TtmServer
        implements ReadableTtmServer, WritableTtmServer, SearchableTtmServer
    {
        /**
    Severity: Minor
    Found in src/TtmServer/ElasticSearchTtmServer.php - About 4 hrs to fix

      Method formatChange has 104 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function formatChange(
              MessageGroup $group,
              MessageSourceChange $changes,
              string $language,
              string $type,
      Severity: Major
      Found in src/Synchronization/ManageGroupsSpecialPage.php - About 4 hrs to fix

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

            public function execute( $parameters ) {
                $this->setHeaders();
        
                $user = $this->getUser();
                $request = $this->getRequest();
        Severity: Minor
        Found in src/PageTranslation/PageTranslationSpecialPage.php - About 4 hrs 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 execute has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

            public function execute(): void {
                $params = $this->extractRequestParams();
                $filter = $params['filter'];
        
                $groups = [];
        Severity: Minor
        Found in src/MessageGroupProcessing/QueryMessageGroupsActionApi.php - About 4 hrs 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

        Method execute has 102 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function execute( $par ) {
                $request = $this->getRequest();
        
                $purge = $request->getVal( 'action' ) === 'purge';
                if ( $purge && !$request->wasPosted() ) {
        Severity: Major
        Found in src/Statistics/MessageGroupStatsSpecialPage.php - About 4 hrs to fix

          Function positionElement has 100 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function positionElement( $targetElem, options ) {
              // Make a copy, we don't want to modify arguments
              options = $.extend( {}, options );
          
              var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
          Severity: Major
          Found in resources/src/ext.translate.groupselector/ui.position.js - About 4 hrs to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                        if (pointAfter && !pointAfter.model.skip) {
                            deltaX = (pointAfter.model.x - pointCurrent.model.x) / 3;
                            pointCurrent.model.controlPointNextX = pointCurrent.model.x + deltaX;
                            pointCurrent.model.controlPointNextY = pointCurrent.model.y + deltaX * pointCurrent.mK;
                        }
            Severity: Major
            Found in resources/lib/Chart.js/Chart.js and 1 other location - About 3 hrs to fix
            resources/lib/Chart.js/Chart.js on lines 10563..10567

            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 114.

            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

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                        if (pointBefore && !pointBefore.model.skip) {
                            deltaX = (pointCurrent.model.x - pointBefore.model.x) / 3;
                            pointCurrent.model.controlPointPreviousX = pointCurrent.model.x - deltaX;
                            pointCurrent.model.controlPointPreviousY = pointCurrent.model.y - deltaX * pointCurrent.mK;
                        }
            Severity: Major
            Found in resources/lib/Chart.js/Chart.js and 1 other location - About 3 hrs to fix
            resources/lib/Chart.js/Chart.js on lines 10568..10572

            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 114.

            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

            Further Reading

            Function listGroups has 98 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function listGroups( groupList, parentGrouppath, $parent, level ) {
                    var selectedClass = '',
                        maxListSize = 10,
                        currentGroup = $( '.facet.groups' ).data( 'group' ),
                        resultCount = groupList.length;
            Severity: Major
            Found in resources/js/ext.translate.special.searchtranslations.js - About 3 hrs to fix

              Function getPageMoveCollection has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getPageMoveCollection(
                      Title $source,
                      ?Title $target,
                      User $user,
                      string $reason,
              Severity: Minor
              Found in src/PageTranslation/TranslatableBundleMover.php - About 3 hrs 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 readFromVariable has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function readFromVariable( string $data ): array {
                      $data = TextContent::normalizeLineEndings( $data );
                      $lines = array_map( 'ltrim', explode( "\n", $data ) );
                      $authors = $messages = [];
                      $lineContinuation = false;
              Severity: Minor
              Found in src/FileFormatSupport/JavaFormat.php - About 3 hrs 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 readFromVariable has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function readFromVariable( string $data ): array {
                      $lines = explode( "\n", $data );
                      $authors = $messages = [];
                      $linecontinuation = false;
              
              
              Severity: Minor
              Found in src/FileFormatSupport/AppleFormat.php - About 3 hrs 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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                          text = text.replace( /(^#.*(\n|$))+/gm, function ( match ) {
                              match = match.replace( /^#(.*)/gm, function ( fullMatch, p1 ) {
                                  return $( '<div>' ).append( $( '<li>' ).html( p1 ) ).html();
                              } );
                              return $( '<div>' ).append( $( '<ol>' ).html( match ) ).html();
              Severity: Major
              Found in resources/js/ext.translate.parsers.js and 1 other location - About 3 hrs to fix
              resources/js/ext.translate.parsers.js on lines 38..43

              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 113.

              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

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                          text = text.replace( /(^\*.*(\n|$))+/gm, function ( match ) {
                              match = match.replace( /^\*(.*)/gm, function ( fullMatch, p1 ) {
                                  return $( '<div>' ).append( $( '<li>' ).html( p1 ) ).html();
                              } );
                              return $( '<div>' ).append( $( '<ul>' ).html( match ) ).html();
              Severity: Major
              Found in resources/js/ext.translate.parsers.js and 1 other location - About 3 hrs to fix
              resources/js/ext.translate.parsers.js on lines 45..50

              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 113.

              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

              Further Reading

              Method onLoadExtensionSchemaUpdates has 97 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function onLoadExtensionSchemaUpdates( $updater ) {
                      $dir = dirname( __DIR__, 1 ) . '/sql';
                      $dbType = $updater->getDB()->getType();
              
                      if ( $dbType === 'mysql' || $dbType === 'sqlite' ) {
              Severity: Major
              Found in src/SchemaHookHandler.php - About 3 hrs to fix
                Severity
                Category
                Status
                Source
                Language