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

Fix function comments with CodeLingo. #336

Merged
merged 3 commits into from
Dec 2, 2018
Merged

Fix function comments with CodeLingo. #336

merged 3 commits into from
Dec 2, 2018

Conversation

BlakeMScurr
Copy link
Contributor

@BlakeMScurr BlakeMScurr commented Nov 28, 2018

Use CodeLingo to automatically fix function comments following the
effective go guidelines mentioned in CONTRIBUTING.md.

This patch was generated by running the CodeLingo Rewrite Flow over the "comment-first-word-as-subject" Tenet.

Note: the same Tenet can be used to automate PR reviews and generate guideline docs.

Install CodeLingo: codelingo.io

@codecov-io
Copy link

codecov-io commented Nov 28, 2018

Codecov Report

Merging #336 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #336   +/-   ##
=======================================
  Coverage   94.43%   94.43%           
=======================================
  Files          13       13           
  Lines        1797     1797           
=======================================
  Hits         1697     1697           
  Misses         97       97           
  Partials        3        3
Impacted Files Coverage Δ
pkg/commands/git.go 93.37% <ø> (ø) ⬆️
pkg/commands/os.go 83.95% <ø> (ø) ⬆️
pkg/commands/commit.go 0% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55712f5...181f91d. Read the comment docs.

@glvr182
Copy link
Contributor

glvr182 commented Nov 29, 2018

Interesting, I didn't know this tool existed. Is it also able to add comments where non exist?

@BlakeMScurr
Copy link
Contributor Author

BlakeMScurr commented Nov 29, 2018

@glvr182 It sure can! In fact I just added that capability codelingo/codelingo#266.

Adding a meaningful comment is really an NLP problem, which is not something that CodeLingo focusses on (yet), but we can append placeholder comments with these few lines:

import codelingo/ast/go

@rewrite --prepend --line "// {{funcName}} is a function."
go.func_decl(depth = any):
  exclude:
    go.comment_group
  go.ident:
    name as funcName
    public == "true"

@BlakeMScurr
Copy link
Contributor Author

Obviously "// {{funcName}} is a function." is not a massively useful comment, but at least it brings attention to the problem. And you can use CodeLingo to review as well as rewrite - it can comment on your pull requests when you write a function that's missing a comment, then a human can manually write it.

@BlakeMScurr
Copy link
Contributor Author

Actually I just found out that we’re working on an interactive review command which would come in really handy here. You’ll be able to install our CLI tool and run lingo run rewrite which will prompt you to write your own comment where none exists. Would you guys like to be our alpha testers for it?

@BlakeMScurr
Copy link
Contributor Author

@jesseduffield
Copy link
Owner

Sounds cool to me, I'm happy to alpha test

@jesseduffield jesseduffield merged commit 6006055 into jesseduffield:master Dec 2, 2018
@jesseduffield
Copy link
Owner

thanks for making this PR btw, very cool :)

@BlakeMScurr
Copy link
Contributor Author

No problem I'm glad you like it! You can get it running automated code reviews on all your PRs by installing our GitHub app https://github.com/apps/codelingo.

The fun part is definitely writing your own custom tenets (linter/rewrite rules) though - so feel free to hop in our slack :)

@BlakeMScurr BlakeMScurr deleted the auto-fix-function-comments branch December 3, 2018 04:57
@BlakeMScurr
Copy link
Contributor Author

By the way, it'd be great to get a tweet if you're up for it. Something like "@codelingoapp just fixed my bugs!" Thank you!

@CodeLingoBot CodeLingoBot mentioned this pull request Dec 19, 2018
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.

4 participants