-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Add check for ungenerated code #679
Conversation
generation/check-for-git-changes.sh
Outdated
set -e | ||
|
||
if [[ $(git diff) ]]; then | ||
echo "Git shows that there are changes." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be more explicit in these logs.
- What happened ?
- Why did it happen ?
- What should the user do now in order to resolve it ?
7ddc373
to
a09fa44
Compare
Added meaningful error message
@rotemmiz added error message, could you review it again? |
a09fa44
to
c2e51c4
Compare
@@ -19,18 +17,27 @@ GREYCondition::waitWithTimeout:pollInterval: | |||
@param seconds Amount of time to wait for the condition to be met, in seconds. | |||
|
|||
@return @c YES if the condition was met before the timeout, @c NO otherwise. | |||
*/static waitWithTimeout(element, seconds) { | |||
if (typeof seconds !== "number") throw new Error("seconds should be a number, but got " + (seconds + (" (" + (typeof seconds + ")")))); | |||
*/ static waitWithTimeout( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the crazy working of prettier? This is bad formatting IMO. It's much harder to actually read the function signature like this.
npm run build | ||
|
||
if [[ $TRAVIS && $(git diff) ]]; then | ||
printf "\n\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
generation/index.js
Outdated
@@ -1,4 +1,7 @@ | |||
#!/usr/bin/env node | |||
const prettier = require("prettier"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, here it is...
@rotemmiz I understood that we wanted to use prettier in our project, so I thought adding it to the generated code too makes sense. I think we are doing a suboptimal job enforcing it, I would offer to help with that. The mockserver I am currently writing enforces it with the help of jest, which I like very much, you can see the config here. I found this quote on a podcast I listen to (freely quoted as I don't remember when they said it):
This resonated a lot with me, I think everyone has an opinion on how code should be looking like for whatever (totally) reasons. prettier frees us from having to have conversations about how it should look like, it just always looks the same, freeing up brain cycles for more important tasks 😇 |
You're right but I still really don't like these formatting choices. It makes the code longer (in lines), and very weirdly formatted. |
Prettier has a nice playground and at the bottom left corner there is a "Show Options" button where you can play with the options until you like the output ;) |
*/static assertWithMatcher(element, matcher) { | ||
if (typeof matcher !== "object" || matcher.type !== "Invocation" || typeof matcher.value !== "object" || typeof matcher.value.target !== "object" || matcher.value.target.value !== "GREYMatchers") { | ||
throw new Error('matcher should be a GREYMatcher, but got ' + JSON.stringify(matcher)); | ||
*/ static assertWithMatcher( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out this is not "prettier being prettier".
Prettier doing a really bad job here because of the */
is at the same line as the function deceleration.
If you make sure docs and function declarations are in different lines it will work quite good.
Here's a config I feel ok with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @DanielMSchmidt , can you please take a look at this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on it, thank you for pinging 👍
775281b
to
5f435e9
Compare
@rotemmiz I think we are there now, please take another look 🙏 Might make sense to go over it commit by commit as the changeset is quite big due to prettier being unleashed on the generated code |
I hate this argument as well, but please use spaces. Tabs make it much harder to read on GitHub, and we spend a lot of time reviewing here |
@rotemmiz done 👍 Did I copy the rest of your prettier session correctly? |
if (typeof point !== "object") throw new Error("point should be a object, but got " + (point + (" (" + (typeof point + ")")))); | ||
if (typeof point.x !== "number") throw new Error("point.x should be a number, but got " + (point.x + (" (" + (typeof point.x + ")")))); | ||
if (typeof point.y !== "number") throw new Error("point.y should be a number, but got " + (point.y + (" (" + (typeof point.y + ")")))); | ||
*/ static actionForMultipleTapsWithCountAtPoint( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still here!
separate */ static actionForMultipleTapsWithCountAtPoint(
to
*/
static actionForMultipleTapsWithCountAtPoint(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't do much about it, this would be something we would need to do in prettier itself, providing an upstream PR. Do you really want me to spend the time there? Would be fine with that, just wanted to clarify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not related to prettier, it's the code generator
Unfortunately, I can't do much about it. I add a
Which route would you like to take? 😇 |
4 |
Okay :) |
You settled for option 4 - let it be like this, so I dismiss your review
@rotemmiz Could you give a final review here? 😇 |
@@ -126,21 +167,25 @@ to be selected. | |||
|
|||
@return An interaction (assertion or an action) to be performed on the element at the | |||
specified index in the list of matched elements. | |||
*/static atIndex(element, index) { | |||
if (typeof index !== "number") throw new Error("index should be a number, but got " + (index + (" (" + (typeof index + ")")))); | |||
*/ static atIndex( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still broken here :/
The current state where the end of multiline comment is at the beginning of the function declaration fucks up prettier. |
51b8214
to
7ef345f
Compare
@rotemmiz I removed prettier from the generated code (only applied the new style to the code generation). I opened an issue at prettier/prettier#4465 let's see if we can get any help there. I might investigate if there is a quick fix within prettier that doesn't take too long. |
.prettierrc
Outdated
@@ -0,0 +1,8 @@ | |||
{ | |||
"useTabs": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useTabs:false!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, forgot to squash one of the commits I dropped
In this step we also changed the config to standards that match our code styles better.
This file gets rewritten with an npm install, so it leads to unnecessary changes
7ef345f
to
a27e2f2
Compare
@rotemmiz Sorry for the typo :/ |
@DanielMSchmidt can you please take a look, seems like the build is broken due to this change. |
Yay, the check works. But damn, need to fix them 😂 will do that asap and ping you :) |
We had at times updates of the source for code generation not being reflected in the adapters as the code was not generated again. Let's add a check for this here 👍