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

Suggested changes #1752

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open

Suggested changes #1752

wants to merge 26 commits into from

Conversation

salbertson
Copy link
Member

No description provided.

Copy link
Member

@gylaz gylaz left a comment

Choose a reason for hiding this comment

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

Neat!

app/services/suggest_changes.rb Show resolved Hide resolved
spec/requests/builds_spec.rb Outdated Show resolved Hide resolved
@salbertson salbertson requested a review from gylaz November 15, 2019 19:53
@salbertson salbertson marked this pull request as ready for review November 16, 2019 18:12
app/models/violation.rb Outdated Show resolved Hide resolved
app/services/suggest_changes.rb Show resolved Hide resolved
app/services/suggest_changes.rb Show resolved Hide resolved
db/migrate/20191108222026_add_source_to_violations.rb Outdated Show resolved Hide resolved
doc/SECURITY.md Outdated
We do not save any of your code in Postgres.
We do store the contents of the files to review temporarily in Sidekiq, and it
gets cleared out as soon as the job is processed.
We store single lines of your code in Postgres, which is encrypted and encoded
Copy link
Member

Choose a reason for hiding this comment

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

How about explaining this a bit more:

We only store single lines of code that we detected a linter violation

Or something? So we explain exactly which lines we store.

doc/SECURITY.md Outdated Show resolved Hide resolved
app/models/violation.rb Outdated Show resolved Hide resolved
@salbertson salbertson requested a review from gylaz November 26, 2019 06:23
@salbertson salbertson self-assigned this Nov 26, 2019
@hound hound bot deleted a comment from salbertson Mar 26, 2020
@hound hound bot deleted a comment from gylaz Mar 26, 2020
@hound hound bot deleted a comment from salbertson Mar 26, 2020
@hound hound bot deleted a comment from salbertson Mar 26, 2020
@hound hound bot deleted a comment from gylaz Mar 26, 2020
Copy link
Member

@gylaz gylaz left a comment

Choose a reason for hiding this comment

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

Couple of comments. LGTM.

app/services/suggest_changes.rb Show resolved Hide resolved
when /Put a comma after the last parameter of a multiline method call/
self.suggestion = violation.source << ","
when /Missing semicolon/
self.suggestion = violation.source << ";"
Copy link
Member

Choose a reason for hiding this comment

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

Dos violation.source << ";" mutate the violation.source? Maybe + or interpolation is safer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, good call. Done.

suggested changes. The data is encrypted and encoded similar to tokens using
`ActiveSupport::MessageEncryptor`. We also store the contents of the files to
review temporarily in Redis, but that is removed as soon as the Sidekiq job is
processed.
Copy link
Member

Choose a reason for hiding this comment

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

👍

result = suggest_changes.call

expect(result).to eq <<~COMMENT.chomp
Put a comma after the last parameter of a multiline method call.<br>```suggestion
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about adding \n before or after <br> in the code, so these assertions don't look so whacky?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure what you mean. If I do that then the tests will fail because the messages won't match. 😕

Copy link
Member

Choose a reason for hiding this comment

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

I'm referring to this line: https://github.com/houndci/hound/pull/1752/files#diff-326c371081e0ec9a5f273d1c45b64541R20

If we add an \n, like:

messages + "\n<br>```suggestion\n#{suggestion}\n```"

then this test line would look like:

Put a comma after the last parameter of a multiline method call.
<br>```suggestion

Copy link
Member Author

Choose a reason for hiding this comment

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

@gylaz works for me, done.


def apply_suggestion(message)
case message
when /Trailing whitespace detected/
Copy link
Member Author

Choose a reason for hiding this comment

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

@gylaz we need to figure out a better way to generate these suggestions.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, though not sure how "smart" we want to get about these.

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.

2 participants