←back to thread

327 points AareyBaba | 1 comments | | HN request time: 0.379s | source
Show context
time4tea ◴[] No.46184345[source]
a = a; // misra

Actual code i have seen with my own eyes. (Not in F-35 code)

Its a way to avoid removing an unused parameter from a method. Unused parameters are disallowed, but this is fine?

I am sceptical that these coding standards make for good code!

replies(11): >>46184442 #>>46184460 #>>46184571 #>>46185232 #>>46185373 #>>46186276 #>>46186377 #>>46186457 #>>46186510 #>>46186705 #>>46189488 #
ivanjermakov ◴[] No.46184571[source]
Zig makes it explicit with

    _ = a;
And you would encounter it quite often because unused variable is a compilation error: https://github.com/ziglang/zig/issues/335
replies(2): >>46185933 #>>46185991 #
ErroneousBosh ◴[] No.46185933[source]
Golang is exactly the same.

It's extremely annoying until it's suddenly very useful and has prevented you doing something unintended.

replies(2): >>46186034 #>>46186865 #
bluecalm ◴[] No.46186034[source]
I fail to see how a warning doesn't achieve the same thing while allowing you to iterate faster. Unless you're working with barbarians who commit code that complies with warnings to your repo and there is 0 discipline to stop them.
replies(3): >>46188913 #>>46189743 #>>46191081 #
FieryMechanic ◴[] No.46191081[source]
> I fail to see how a warning doesn't achieve the same thing while allowing you to iterate faster.

In almost every code base I have worked with where warnings weren't compile errors, there were hundreds of warnings. Therefore it just best to set all warnings as errors and force people to correct them.

> Unless you're working with barbarians who commit code that complies with warnings to your repo and there is 0 discipline to stop them.

I work with a colleague that doesn't compile/run the code before putting up a MR. I informed my manager who did nothing about it after he did it several times (this was after I personally told him he needed to do it and it was unacceptable).

This BTW this happens more often than you would expect. I have read PRs and had to reject them because I read the code and they wouldn't have worked, so I know the person had never actually run the code.

I am quite a tidy programmers, but it difficult for people even to write commit messages that aren't just "fixed bugs".

replies(2): >>46196921 #>>46203407 #
1. ErroneousBosh ◴[] No.46196921[source]
> I work with a colleague that doesn't compile/run the code before putting up a MR. I informed my manager who did nothing about it after he did it several times (this was after I personally told him he needed to do it and it was unacceptable).

At this point what you need to do is stop treating compiler warnings as errors, and just have them fire the shock collar.

Negative reinforcement gets a bad rep, but it sure does work.