Skip to content

Adding linters take 2#425

Merged
milos-lk merged 3 commits intomainfrom
linters-take-2
Mar 31, 2026
Merged

Adding linters take 2#425
milos-lk merged 3 commits intomainfrom
linters-take-2

Conversation

@milos-lk
Copy link
Copy Markdown
Contributor

Using the same linter configuration as for egress. Bunch of errors some outlining real bugs.
Majority of linter errors fixed:

  • unused params
  • depricated APIs
  • returning unexported types
  • typos
  • unchecked errors
  • bug with using TrimLeft
  • bug with copying mutex (part of copied proto message)
  • big param list (not really fixed - just disabled for now to avoid big changes)

Using the same linter configuration as for egress.
Bunch of errors some outlining real bugs.
Majority of linter errors fixed:
- unused params
- depricated APIs
- returning unexported types
- typos
- bug with using TrimLeft
- bug with copying mutex (part of copied proto message)
- big param list (not really fixed - just disabled for now to avoid big changes)
Copy link
Copy Markdown

@boks1971 boks1971 left a comment

Choose a reason for hiding this comment

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

this is great @milos-lk !!!


err = o.preProcessorElements[len(o.preProcessorElements)-1].Link(o.tee)
if err != nil {
return nil, err
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Were we hitting this before and ignoring?

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.

No, if this link failed - the pipeline would be broken, the tee element would have no input. So this will cause gstreamer to error out when pipeline starts (not connected) and produce an error that would be a bit cryptic. I don't see that happening from logs. Realistically this probably never fails. It looks just like forgotten error check. Maybe @biglittlebigben or @frostbyte73 could double check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should definitely add the check, even if unlikely to hit with the current code base. Whether we currently ever hit this and then fail later right now seems a bit academic?

return path.Join(os.TempDir(), info.State.ResourceId)
}

//nolint:revive // argument-limit: refactoring signature would be a larger change
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maybe make the comment about refactoring as an inline PR comment and make it a TODO in code. Reading that code comment some time after now will feel strange :-) You would have to check blame/history to understand that comment


func computeVideoLayers(highLayer *livekit.VideoLayer, layerCount int) []*livekit.VideoLayer {
layerCopy := *highLayer
layerCopy := proto.Clone(highLayer).(*livekit.VideoLayer)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We have a utils.CloneProto in protocol repo which we have started using as a standard way to clone protobuf. Would be good to see if that is usable here also.

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.

that's very neat - replacing.

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.

we have couple more of explicit proto.Clone calls which could be replaced - replacing them as well.

}
}

//nolint:revive // TODO(milos) reduce argument count
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

made a comment earlier, meant to say something like this is better for code comment.

depacketizer := &codecs.VP8Packet{}

b, err := depacketizer.Unmarshal(pkt.Payload)
if err != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

was this error not happening before?

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 was also asking myself this question when I modified this - thanks for bringing it up - I should have explicitly mentioned it - as far as I can see - before this return - the error will be emitted by the decoder (reader with 0 bytes - something like unexpected EOF). Functionally nothing changes now other than hopeful having more precise error message if this ever happens (don't see it happening from logs for the past month).

Copy link
Copy Markdown
Contributor

@biglittlebigben biglittlebigben left a comment

Choose a reason for hiding this comment

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

Thanks!


err = o.preProcessorElements[len(o.preProcessorElements)-1].Link(o.tee)
if err != nil {
return nil, err
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should definitely add the check, even if unlikely to hit with the current code base. Whether we currently ever hit this and then fail later right now seems a bit academic?

return path.Join(os.TempDir(), info.State.ResourceId)
}

//nolint:revive // TODO(milos): reduce argument count
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, this got out of hand 1 argument at a time. That's case where linters are good to keep you in check.

@milos-lk milos-lk merged commit b62303d into main Mar 31, 2026
9 checks passed
@milos-lk milos-lk deleted the linters-take-2 branch March 31, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants