Skip to content

fix(general): clean up typos and code #62

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

Merged
merged 4 commits into from
Sep 1, 2020

Conversation

michaelbrewer
Copy link
Contributor

Issue #, if available:

Description of changes:

Changes:

  • Fix some of the markdown used
  • Removed unused imports
  • LambdaHandlerProcessor - Make null check easier to read
  • LambdaJsonLayout - Remove unused objectMapper
  • Fix typos

Checklist

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Changes:
* Fix some of the markdown used
* Removed unused imports
* LambdaHandlerProcessor - Make null check easier to read
* LambdaJsonLayout - Remove unused objectMapper
* Fix typos
@msailes
Copy link
Contributor

msailes commented Aug 31, 2020

Thanks for the PR Michael, just looking at this now.

Copy link
Contributor

@pankajagrawal16 pankajagrawal16 left a comment

Choose a reason for hiding this comment

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

@michaelbrewer Thanks for updates to some of the docs and typos. Muck appreciated:) Just one suggestion.

@@ -22,7 +22,7 @@
import org.aspectj.lang.ProceedingJoinPoint;

public final class LambdaHandlerProcessor {
private static String SERVICE_NAME = null != System.getenv("POWERTOOLS_SERVICE_NAME")
private static String SERVICE_NAME = System.getenv("POWERTOOLS_SERVICE_NAME") != null
Copy link
Contributor

Choose a reason for hiding this comment

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

In order to keep it consistent with how we will like to check for null, I will prefer if we keep constant(null) to the left.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok sure, i can revert this, just confusing to read left to right.

Maybe this would be cleaner and work with java8

private static String SERVICE_NAME = Optional.ofNullable(System.getenv("POWERTOOLS_SERVICE_NAME")).orElse("service_undefined")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pankajagrawal16 SERVICE_NAME and IS_COLD_START look like constants, but are actually mutable due to the unit tests requiring this to be mutable. Maybe we should change either the unit tests or these misleading names.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok sure, i can revert this, just confusing to read left to right.

Maybe this would be cleaner and work with java8

private static String SERVICE_NAME = Optional.ofNullable(System.getenv("POWERTOOLS_SERVICE_NAME")).orElse("service_undefined")

We have intentionally avoided use of optional here considering its a simple null check which belongs to an internal class.

I am a big fan of functional interfaces in java myself and have to always find a balance when I would like to use it.

Prefer using optional on public API that is public to let users ability to write functional code and not worry about nulls.

But these are just personal preferences too. Considering this being a internal class, I will still be happy to leave it the way it was. Thanks for the input. 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pankajagrawal16 - ok i reverted back to the original code.

@michaelbrewer
Copy link
Contributor Author

@pankajagrawal16 - maybe where possible we make things final as it reduces any kind of side effects. I just did not want to make too many trivial changes.

Maybe there anti-bike shedding type of autoformatter do java like "black" for python or "ktlint" for kotlin. To clean up imports and naming conversions.

@pankajagrawal16
Copy link
Contributor

@pankajagrawal16 - maybe where possible we make things final as it reduces any kind of side effects. I just did not want to make too many trivial changes.

Maybe there anti-bike shedding type of autoformatter do java like "black" for python or "ktlint" for kotlin. To clean up imports and naming conversions.

Having autoformatter sounds like a good idea, but I will suggest please open a RFC for it so that we can track it. As far as client of the library is concerned, it doesn't impact them directly, but definitely worth evaluating at some point.

Copy link
Contributor

@pankajagrawal16 pankajagrawal16 left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@pankajagrawal16 pankajagrawal16 merged commit 8fb14e4 into aws-powertools:master Sep 1, 2020
@michaelbrewer michaelbrewer deleted the fix-cleanup branch December 11, 2021 04:29
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