vmware / build-tools-for-vmware-aria

Build Tools for VMware Aria provides development and release management tools for implementing automation solutions based on the VMware Aria Suite and VMware Cloud Director. The solution enables Virtual Infrastructure Administrators and Automation Developers to use standard DevOps practices for managing and deploying content.
Other
48 stars 24 forks source link

Commenting bug #415

Closed unbreakabl3 closed 2 months ago

unbreakabl3 commented 2 months ago

Description

In TS vRO project, there is a bug. When in the commented code there is a for each instead of foreach, the transpiled code in vRO uncomments this line.

Example:

// Code...
// for each (var device in devices) {...}
// Code...

Will be transpiled to

// Code...
var device = devices[$index_device];
// Code...

If I remove the space in the commented for each, the code is commented properly.

Steps to Reproduce

  1. Write for each loop with a space between for and each
  2. Comment it
  3. Check the code in vRO

Preconditions: [What are the preconditions to reproduce the issue]

Expected behavior: [What you expect to happen]

The comment should comment anything

Actual behavior: [What actually happens]

The doesn't work properly in some cases

Reproduces how often: [What percentage of the time does it reproduce]

All the time

Component/s: [What are the Build Tools for VMware Aria components affected by the issue (e.g. "common/artifact-manager", "maven/plugins/vra-ng", "typescript/vrotest", etc)]

vRO TS Project

Affects Build/s: [Which are the Build Tools for VMware Aria releases / builds affected by the issue]

2.41.0

Environment

Client

Server

Failure Logs

Related issues and PRs

Additional Context

Michaelpalacce commented 2 months ago

So I know where this happenns specifically... it's in the vropkg/src/parse/transformers.ts. It's actually something I wrote a while back to solve a use case and automatically transform these cases.

Problem Is, the regex is already complex and absurd enough as is... that I am not sure I want us to fiddle with it even further...

Should be something like:

https://regex101.com/r/K2cJ8Q/2

^(?!\s*(\/\/|\/\*|\*\/|\*)).*for each\s*\(\s*var\s+(\w+)\s+in\s+(\w+)\s*\)\s*\{\s*([\s\S]*?)\s*\}

But this also may cause other problems as it looks for * in the beginning as well as / or // … The latter 2 don't bother me, but `` may be a problem. Also, it looks atrocious 😄

Michaelpalacce commented 2 months ago

@VenelinBakalov what do you say?

Michaelpalacce commented 2 months ago

As discussed with @VenelinBakalov, we'll do it.