Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command line tools for XML sync testing between languages #222

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alfsb
Copy link
Member

@alfsb alfsb commented Feb 14, 2025

This PR rewrites the last of old qaxml tools into something that is almost independent of "lib revcheck" code, and adapted to be run in all translations.

After this PR is merged, and new tools announced, the old tools/code removing will be possible. The only dependence renaming are /lib/RevtagParser.php, that is a isolated file, and SyncFileList calling into RevcheckRun, that can be replaced with a simple .xml listing, as the new tools now inspect all files, and does not filter for TranslatedOk anymore.

@alfsb alfsb requested review from cmb69 and Girgias February 14, 2025 16:05
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the coding style choices are exotic and not even consistent within the same file.

if ( implode( "\n" , $s ) == implode( "\n" , $t ) )
continue;

$sideCount = array();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$sideCount = array();
$sideCount = [];


function extractPiData( array $list )
{
$ret = array();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ret = array();
$ret = [];

Comment on lines +48 to +50
foreach( $s as $v )
$sideCount[$v] = [ 0 , 0 ];
foreach( $t as $v )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this coding style. Usually it would be something like:

Suggested change
foreach( $s as $v )
$sideCount[$v] = [ 0 , 0 ];
foreach( $t as $v )
foreach ($s as $v)
$sideCount[$v] = [ 0 , 0 ];
foreach ($t as $v)

continue;

print "# qaxml.r: $target\n";
foreach( $revtag->errors as $error )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

if ( implode( "\n" , $s ) == implode( "\n" , $t ) )
continue;

$sideCount = array();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$sideCount = array();
$sideCount = [];


function extractTagsInnerText( array $nodes , array $tags )
{
$ret = array();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$ret = array();
$ret = [];

if ( in_array( $tag , $tags ) == false )
continue;
$text = $node->textContent;
while( true )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly CS which I don't understand.


function extractTagsInnerXmls( array $nodes , array $tags )
{
$ret = array();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Comment on lines +278 to +280
}
else
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Suggested change
}
else
{
} else {


function collectTagLines( string $file , string $tag )
{
$ret = array();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

$s = extractPiData( $s );
$t = extractPiData( $t );

if ( implode( "\n" , $s ) == implode( "\n" , $t ) )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be ===? I think it would make more sense.

$target = $file->targetDir . '/' . $file->file;
$output = new OutputBuffer( "# qaxml.p" , $target , $ignore );

[ $s , $_ , $_ ] = XmlFrag::loadXmlFragmentFile( $source );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you reusing the variable $_ twice? It's just going to overwrite it. And I don't think you are actually using this variable anywhere so why assign it at all?

Comment on lines +37 to +38
$s = XmlFrag::listNodes( $s , XML_PI_NODE );
$t = XmlFrag::listNodes( $t , XML_PI_NODE );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$s = XmlFrag::listNodes( $s , XML_PI_NODE );
$t = XmlFrag::listNodes( $t , XML_PI_NODE );
$s = XmlFrag::listNodes( $s , XML_PI_NODE );
$t = XmlFrag::listNodes( $t , XML_PI_NODE );
Suggested change
$s = XmlFrag::listNodes( $s , XML_PI_NODE );
$t = XmlFrag::listNodes( $t , XML_PI_NODE );
$source = XmlFrag::listNodes( $source , XML_PI_NODE );
$target = XmlFrag::listNodes( $target , XML_PI_NODE );

Please don't use single-character variable names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants