alecthomas / SublimeLinter-contrib-gometalinter

SublimeLinter plugin for gometalinter
MIT License
47 stars 13 forks source link

Take care, you must be thread aware #14

Closed kaste closed 6 years ago

kaste commented 6 years ago

Something like the follwing is not thread aware.

https://github.com/alecthomas/SublimeLinter-contrib-gometalinter/blob/12714f92b00bbc205970ade5c0cc6e5b52f99756/linter.py#L42

T.i. do not modify self during execution. Currently only instantiation of the linter is guarded.

Users can modify the execution environment directly by setting 'env': {...}. Common Sublime variables (like $folder, ~ etc.) are supported here. Then you probably don't need __init__ which copies os.environ

alecthomas commented 6 years ago

That code was previously in the constructor but had to be moved because it failed to work in SublimeLinter 4.

It seems like the correct approach is to do nothing and rely on the user setting the env fields appropriately?

kaste commented 6 years ago

Since you do your own thing, it is not enough to do nothing. You must at some point get the env using get_environment(settings) and then pass this down.

alecthomas commented 6 years ago

Is this documented somewhere?

kaste commented 6 years ago

Yes, here

https://github.com/SublimeLinter/SublimeLinter/blob/413b00404f8f8906ea1bd4a8659dc118531d9332/lint/linter.py#L1161-L1188

LOL

alecthomas commented 6 years ago

Thank you!

I think d04b85cc806f5e4a4d478c84c70c0e9eda4c4635 should be correct.