Skip to content
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

MB-10168-custom-linter-doc #49

Merged
merged 7 commits into from
Dec 1, 2021
Merged

Conversation

NamibiaTorres
Copy link
Contributor

Description:

In this document I wrote a how-to guide for creating Custom Go linters in MyMove and linked to resources that helped us write our linters.

Note for reviewer:

-Please leave feedback on how readable this guide is. Are the instructions clear? Is there anything missing?

@NamibiaTorres NamibiaTorres requested a review from a team November 24, 2021 01:33
Copy link
Contributor

@felipe-lee felipe-lee left a comment

Choose a reason for hiding this comment

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

Overall this looks great, thanks for putting it together!

I added some comments and suggestions, but am happy to discuss any of them more in depth if you'd like.

docs/backend/guides/how-to/create-a-custom-linter.md Outdated Show resolved Hide resolved
docs/backend/guides/how-to/create-a-custom-linter.md Outdated Show resolved Hide resolved
docs/backend/guides/how-to/create-a-custom-linter.md Outdated Show resolved Hide resolved
docs/backend/guides/how-to/create-a-custom-linter.md Outdated Show resolved Hide resolved
docs/backend/guides/how-to/create-a-custom-linter.md Outdated Show resolved Hide resolved
docs/backend/guides/how-to/create-a-custom-linter.md Outdated Show resolved Hide resolved
docs/backend/guides/how-to/create-a-custom-linter.md Outdated Show resolved Hide resolved
Copy link
Contributor

@felipe-lee felipe-lee left a comment

Choose a reason for hiding this comment

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

Thanks for making those updates! I just have a few more comments

docs/backend/guides/how-to/create-a-custom-linter.md Outdated Show resolved Hide resolved
docs/backend/guides/how-to/create-a-custom-linter.md Outdated Show resolved Hide resolved

The linter is actually analyzing an abstract syntax tree, AST, that represents code in a file.
When your linter gets to a position in a file, where it catches an error, bug, or issue, it will flag this for the user.
Because the linter is analyzing an AST, your code must be able to search through a file and mark which position it is when an issue is caught.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if it would be good or not to include an example of what it looks like to mark a position with a message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean?

Copy link
Contributor

Choose a reason for hiding this comment

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

Like showing an example like this:
https://github.com/transcom/mymove/blob/d8d2b3862a28b344a1afdbb1a781d6529f04feb8/pkg/appcontext-linter/appctx.go#L46

To show that you call the .Pos() method on an AST object to get its position and pass that along with a message to pass.Reportf to report an issue found in the code. Maybe this is getting to specific though and they should just get that from reading the linked article on how to write the run function.

Copy link
Contributor

@felipe-lee felipe-lee left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for making those changes. The only comment left is the one about .Pos(), but I'll leave it up to you whether you want to include that or not.

Copy link
Contributor

@felipe-lee felipe-lee left a comment

Choose a reason for hiding this comment

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

LGTM!

@NamibiaTorres NamibiaTorres merged commit 058cd32 into main Dec 1, 2021
@NamibiaTorres NamibiaTorres deleted the MB-10168-custom-linter-doc branch December 1, 2021 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants