[core-http] Fix formatting errors#4863
Conversation
ramya-rao-a
left a comment
There was a problem hiding this comment.
There are 2 places where the formatter changes makes the code very hard to read.
With a simple pulling of JSON.stringify out into a constant can improve this.
Please make the change in the 2 places.
sdk/core/core-http/lib/util/utils.ts
Outdated
| obj, | ||
| undefined, | ||
| 2 | ||
| )} is not a valid object that can be ` + `enumerated to provide its values as an array.` |
There was a problem hiding this comment.
This one is very hard to read. Please pull JSON.stringify(obj, undefined, 2) out into a constant instead of using it inline. This way the formatter should treat it more kindly
There was a problem hiding this comment.
Oh, this PR is meant to only fix formatting issues.
Lets do refactoring for readability after the end of main implementation (Atom management API)
There was a problem hiding this comment.
Yes, I understand this PR is to fix the formatting so that further PRs would not have the noise and I appreciate the effort.
As you know, formatting tools exist to make it easier for us to maintain coding styles across all files. If at any point, they cause more harm than good, then we should try our best to fix that especially if the fix is very trivial.
This is one such case.
I would prefer to have this fixed now rather than have this PR introduce a new problem and then have another PR to fix it.
Also, there is a high chance that the implementation for the management apis might not touch this line of code and you might want that PR to be restricted to code related to that feature.
There was a problem hiding this comment.
Is the concern with use of JSON.stringify(), or this specific string?
'prettier' formatting is to help with readability and I didn't find this that hard to read too.
It can be pulled out - but this would be a general refactoring effort since JSON.stringify() is going to be used in other parts of implementation as well. So we'll likely need to pull this out elsewhere and not just out within this file.
Let's address this after the implementation is in?
I was hoping to spend less time / review cycles on these as it seems too early to address this.
The purpose was that subsequent changes surfaced in PRs are not related to these, and so this can help bring focus to the implementation first.
Overall, JSON.stringify() will likely be used in multiple places and seems a code cleanup detail which can be addressed at end.
There was a problem hiding this comment.
There is absolutely no problem in the usage of JSON.stringify(). No wide scale refactoring is needed.
The suggestion was to change
throw new Error(
`The provided object ${JSON.stringify(
obj,
undefined,
2
)} is not a valid object that can be ` + `enumerated to provide its values as an array.`
);to
const stringifiedObj = JSON.stringify(obj, undefined, 2);
throw new Error(
`The provided object ${stringifiedObj} is not a valid object that can be ` +
`enumerated to provide its values as an array.`
);| pathParameters, | ||
| undefined, | ||
| 2 | ||
| )}.` + |
There was a problem hiding this comment.
This one is very hard to read. Please pull JSON.stringify(pathParameters, undefined, 2) out into a constant instead of using it inline. This way the formatter should treat it more kindly
Fir formatting issues to prevent noise later.