Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

default discussion title if not provided#271

Merged
nicksnyder merged 5 commits into
masterfrom
discusstitle
Oct 8, 2018
Merged

default discussion title if not provided#271
nicksnyder merged 5 commits into
masterfrom
discusstitle

Conversation

@nicksnyder

Copy link
Copy Markdown
Contributor

@nicksnyder nicksnyder requested a review from emidoots October 4, 2018 23:42
@nicksnyder nicksnyder requested a review from beyang as a code owner October 4, 2018 23:42
Comment thread cmd/frontend/graphqlbackend/discussion_threads.go

if args.Input.Title == nil {
// Title defaults to first line of contents.
title := strings.TrimSpace(strings.SplitN(args.Input.Contents, "\n", 2)[0])

@emidoots emidoots Oct 5, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

args.Input.Contents can start with a bunch of whitespace, in which case we should ignore it:

> 
> 
> my title is here
>
> and my comment..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I do recognize that:

strings.SplitN(args.Input.Contents, "\n", 2)[0]

is more efficient than this:

strings.Split(args.Input.Contents, "\n")[0]

But I think the latter is far more readable and we do not need to care about performance here. For example, I had to look up the exact semantics of the SplitN function to determine that the behavior here is correct.

@nicksnyder nicksnyder Oct 5, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I put the trim before the split, which should solve the first issue.

As far as SplitN goes, I am ambivalent. I am all for readability, and it does require looking at the doc if you don't know it off the top of your head, but I think that is ok. The doc here isn't complicated, and it is a standard library function. Performance doesn't matter that much here, but it is unbounded user input. It seems silly to do something suboptimal when the optimal thing is a few keystrokes away.

Since my name is going to be on the blame, I am going to leave it as-is. You can push a commit after I squash merge if you feel strongly about it.

Comment thread cmd/frontend/graphqlbackend/schema.go Outdated

@emidoots emidoots left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

two requests inline

Comment thread cmd/frontend/graphqlbackend/discussion_threads.go Outdated
@nicksnyder nicksnyder merged commit d299f2c into master Oct 8, 2018
@nicksnyder nicksnyder deleted the discusstitle branch October 8, 2018 14:30
@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #271 into master will decrease coverage by 0.38%.
The diff coverage is 0%.

Impacted Files Coverage Δ
cmd/frontend/graphqlbackend/discussion_threads.go 8.9% <0%> (-0.07%) ⬇️
cmd/symbols/internal/symbols/parse.go 10.65% <0%> (-53.28%) ⬇️
cmd/symbols/internal/symbols/fetch.go 5.33% <0%> (-48%) ⬇️
cmd/frontend/internal/pkg/langservers/config.go 0% <0%> (ø) ⬆️
pkg/phabricator/phabricator.go 0% <0%> (ø)
cmd/symbols/internal/symbols/index.go 49.18% <0%> (+9.83%) ⬆️

@emidoots

emidoots commented Oct 8, 2018

Copy link
Copy Markdown
Member

LGTM, thanks!

BolajiOlajide pushed a commit that referenced this pull request Apr 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants