Skip to content

[cleanup] erefactor/AutoRefactor - Log parameters rather than log mes…#9133

Merged
wing328 merged 1 commit intoOpenAPITools:masterfrom
cal101:erefactor/master/x-judge/LogParametersRatherThanLogMessageCleanUp-3
Jun 7, 2021
Merged

[cleanup] erefactor/AutoRefactor - Log parameters rather than log mes…#9133
wing328 merged 1 commit intoOpenAPITools:masterfrom
cal101:erefactor/master/x-judge/LogParametersRatherThanLogMessageCleanUp-3

Conversation

@cal101
Copy link
Copy Markdown
Contributor

@cal101 cal101 commented Mar 30, 2021

…sage

Example PR for #9097

AutoRefactor cleanup 'LogParametersRatherThanLogMessage' applied by erefactor:

Replaces a string concatenation as parameter of a logger method by a
string template followed by objects.

For AutoRefactor see https://github.com/JnRouvignac/AutoRefactor
For erefactor see https://github.com/cal101/erefactor

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this formatting is strange. baseName is vertically where logged string ends

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As I wrote in the related ticket, the cleanup breaks some formatting.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this still can be improved to {} {} in log message

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Interesting case, may be worth improving the cleanup.

Copy link
Copy Markdown
Member

@wing328 wing328 Apr 1, 2021

Choose a reason for hiding this comment

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

Good catch. We can improve it in another PR as I may have some other enhancements for the ObjC client generator.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@cal101 @agilob not sure why these spaces are added after the refactor. Will file a PR to clean it up manually later instead.

Copy link
Copy Markdown
Contributor

@agilob agilob Apr 1, 2021

Choose a reason for hiding this comment

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

toString also should be removed from refactored code as LOGGER will call that internally if required

@wing328 wing328 added Enhancement: Code Cleanup General refactoring, removal of deprecated things, commenting, etc. Feature: Generator labels Apr 1, 2021
@wing328 wing328 added this to the 5.1.1 milestone Apr 1, 2021
@wing328
Copy link
Copy Markdown
Member

wing328 commented Apr 1, 2021

I cannot merge this as the refactoring uses tabs instead of 4-space (caught by Travis CI). Partial result below:

$ /bin/bash ./bin/utils/detect_tab_in_java_class.sh
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java:					camelize("model_" + modelName));
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java:					camelizedName);
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java:					camelize("call_" + operationId));
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java:					"{} with {} generator is ignored. Setting this value independently of {} is not currently supported.",
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java:					CodegenConstants.MODEL_PACKAGE, this.getName(), CodegenConstants.PACKAGE_NAME);
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java:					"{} with {} generator is ignored. Setting this value independently of {} is not currently supported.",
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java:					CodegenConstants.API_PACKAGE, this.getName(), CodegenConstants.PACKAGE_NAME);
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java:					name, camelize("model_" + name));
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java:					camelize("model_" + name));
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java:					escapeReservedWord(name));
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java:					escapeReservedWord(name));
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java:				"{} is hard coded to true in this generator. Alias models will only be generated if they contain validations or enums",
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java:				CodegenConstants.GENERATE_ALIAS_AS_MODEL);
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java:					camelize("model_" + name));
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java:					camelize("model_" + name));

Can we change the refactoring tool to use 4-space instead of tabs?

@wing328 wing328 modified the milestones: 5.1.1, 5.2.0 May 10, 2021
…sage

AutoRefactor cleanup 'LogParametersRatherThanLogMessage' applied by erefactor:

Replaces a string concatenation as parameter of a logger method by a
string template followed by objects.

For AutoRefactor see https://github.com/JnRouvignac/AutoRefactor
For erefactor see https://github.com/cal101/erefactor
@cal101 cal101 force-pushed the erefactor/master/x-judge/LogParametersRatherThanLogMessageCleanUp-3 branch from d68d750 to 717b325 Compare June 3, 2021 15:56
@cal101
Copy link
Copy Markdown
Contributor Author

cal101 commented Jun 3, 2021

@wing328 Solving the wrong problem took much longer than expected. But solution may be useful for other cases. A bug in the cleanup was fixed and indentation is changed to 4 spaces.

Copy link
Copy Markdown
Member

@wing328 wing328 left a comment

Choose a reason for hiding this comment

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

LGTM

@wing328 wing328 merged commit 3cbc5a8 into OpenAPITools:master Jun 7, 2021
@cal101 cal101 deleted the erefactor/master/x-judge/LogParametersRatherThanLogMessageCleanUp-3 branch June 7, 2021 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement: Code Cleanup General refactoring, removal of deprecated things, commenting, etc. Feature: Generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants