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

chore: Fix linter problems on master. #8930

Merged
merged 1 commit into from
May 4, 2022

Conversation

ajnavarro
Copy link
Member

It looks like go linter was not executed previously. Fix some problems found on the master branch.

I have some concerns about context keys. If they were used somewhere we are breaking backward compatibility.

Signed-off-by: Antonio Navarro Perez antnavper@gmail.com

@ajnavarro ajnavarro requested a review from lidel as a code owner May 3, 2022 15:57
@ajnavarro ajnavarro changed the title Fix linter problems on master. chore: Fix linter problems on master. May 3, 2022
Jorropo
Jorropo previously requested changes May 3, 2022
commands/reqlog.go Outdated Show resolved Hide resolved
core/coreapi/name.go Show resolved Hide resolved
core/corehttp/hostname.go Show resolved Hide resolved
@aschmahmann
Copy link
Contributor

I have some concerns about context keys. If they were used somewhere we are breaking backward compatibility.

I'd probably just add linter ignore messages for these so you can unblock and merge #8928. We can then circle back to resolving them (especially for cross-package issues such as with go-namesys).

Comment on lines 25 to 29
type ctxKey int

const (
CtxKeyIpnsPublishTTL ctxKey = iota
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I just added linter ignore messages.

@ajnavarro ajnavarro force-pushed the fix/linter-on-master branch 2 times, most recently from 4adac10 to 47f4f16 Compare May 4, 2022 08:35
Comment on lines 41 to 48
rle.ID = rl.nextID
rl.nextID++
rl.Requests = append(rl.Requests, rle)

if rle == nil || !rle.Active {
rl.maybeCleanup()
}

rle.ID = rl.nextID
rl.nextID++
rl.Requests = append(rl.Requests, rle)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC this doesn't really fix what the linter was complaining about it just tricks it into being happy.

(SA5011)[https://staticcheck.io/docs/checks#SA5011] is complaining because we did a nil check after we used a reference to the object. However, if rle was actually nil then we'd get a panic here anyway since calling rl.maybeCleanup() doesn't really change anything.

We should either explicitly handle the nil case (e.g. check if nil then emit a log and return), or just remove the nil check which wasn't previously helping us anyway.

Copy link
Member Author

@ajnavarro ajnavarro May 4, 2022

Choose a reason for hiding this comment

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

Being consistent with the rest of the methods, I would say that removing the nil check is ok. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems reasonable to me, it's certainly no worse than what we currently have. We may want to revisit what's going on with the ReqLog later anyway because I see that the code is duplicated here and in https://github.com/ipfs/go-ipfs-cmds/blob/master/reqlog.go and probably one of these should be deleted.

However, we can do this further down the road

Copy link
Contributor

@aschmahmann aschmahmann left a comment

Choose a reason for hiding this comment

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

Looks good, thanks 🙏

@aschmahmann aschmahmann requested a review from Jorropo May 4, 2022 15:00
@aschmahmann aschmahmann dismissed Jorropo’s stale review May 4, 2022 15:01

changes addressed

@aschmahmann aschmahmann merged commit afd11f1 into ipfs:master May 4, 2022
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.

3 participants