AydarZaynutdinov commented on a change in pull request #16172:
URL: https://github.com/apache/beam/pull/16172#discussion_r767551426
##########
File path: playground/backend/internal/preparators/java_preparators.go
##########
@@ -37,15 +39,41 @@ const (
// GetJavaPreparators returns preparation methods that should be applied to
Java code
func GetJavaPreparators(filePath string) *[]Preparator {
- publicClassModification := Preparator{
+ removePublicClassPreparator := Preparator{
Prepare: replace,
Args: []interface{}{filePath,
classWithPublicModifierPattern, classWithoutPublicModifierPattern},
}
- additionalPackage := Preparator{
- Prepare: replace,
+ changePackagePreparator := Preparator{
+ Prepare: changePackage,
Args: []interface{}{filePath, packagePattern,
importStringPattern},
}
- return &[]Preparator{publicClassModification, additionalPackage}
+ removePackagePreparator := Preparator{
+ Prepare: removePackage,
+ Args: []interface{}{filePath, packagePattern,
newLinePattern},
+ }
+ return &[]Preparator{removePublicClassPreparator,
changePackagePreparator, removePackagePreparator}
+}
+
+//changePackage changes the 'package' to 'import' and the last directory in
the package value to '*'
+func changePackage(args ...interface{}) error {
+ valRes := args[3].(*sync.Map)
Review comment:
```suggestion
validationResults := args[3].(*sync.Map)
```
##########
File path: playground/backend/internal/preparators/go_preparators.go
##########
@@ -53,8 +55,9 @@ func formatCode(args ...interface{}) error {
func changeFileName(args ...interface{}) error {
filePath := args[0].(string)
- isUnitTest := args[1].(bool)
- if isUnitTest {
+ valRes := args[1].(*sync.Map)
Review comment:
```suggestion
validationResults := args[1].(*sync.Map)
```
##########
File path: playground/backend/internal/preparators/java_preparators.go
##########
@@ -37,15 +39,41 @@ const (
// GetJavaPreparators returns preparation methods that should be applied to
Java code
func GetJavaPreparators(filePath string) *[]Preparator {
- publicClassModification := Preparator{
+ removePublicClassPreparator := Preparator{
Prepare: replace,
Args: []interface{}{filePath,
classWithPublicModifierPattern, classWithoutPublicModifierPattern},
}
- additionalPackage := Preparator{
- Prepare: replace,
+ changePackagePreparator := Preparator{
+ Prepare: changePackage,
Args: []interface{}{filePath, packagePattern,
importStringPattern},
}
- return &[]Preparator{publicClassModification, additionalPackage}
+ removePackagePreparator := Preparator{
+ Prepare: removePackage,
+ Args: []interface{}{filePath, packagePattern,
newLinePattern},
+ }
+ return &[]Preparator{removePublicClassPreparator,
changePackagePreparator, removePackagePreparator}
+}
+
+//changePackage changes the 'package' to 'import' and the last directory in
the package value to '*'
+func changePackage(args ...interface{}) error {
+ valRes := args[3].(*sync.Map)
+ isKata, ok := valRes.Load(validators.KatasValidatorName)
+ if ok && isKata.(bool) {
+ return nil
+ }
+ err := replace(args...)
+ return err
+}
+
+//removePackage remove the package line in the katas.
+func removePackage(args ...interface{}) error {
+ valRes := args[3].(*sync.Map)
Review comment:
```suggestion
validationResults := args[3].(*sync.Map)
```
##########
File path: playground/backend/internal/executors/executor.go
##########
@@ -76,10 +76,10 @@ func (ex *Executor) Validate() func(chan bool, chan error,
*sync.Map) {
}
// Prepare returns the function that applies all preparations of executor
-func (ex *Executor) Prepare() func(chan bool, chan error, bool) {
- return func(doneCh chan bool, errCh chan error, isUnitTest bool) {
+func (ex *Executor) Prepare() func(chan bool, chan error, *sync.Map) {
+ return func(doneCh chan bool, errCh chan error, valRes *sync.Map) {
Review comment:
```suggestion
return func(doneChannel chan bool, errChannel chan error,
validatonResults *sync.Map) {
```
##########
File path: playground/backend/internal/validators/python_validators.go
##########
@@ -15,7 +15,7 @@
package validators
-// GetPythonValidators return validators methods that should be applied to Go
code
+// GetPythonValidators return validators methods that should be applied to Go
javaCode
Review comment:
`Go javaCode`? For `GetPythonValidators`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]