The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
If you are coding in C++, perhaps you should really examine you code, for example, using assert -- you might want to use the Google Test Framework and use their ASSERT_ macros along with gMock so you don't have to pollute your code with something that is normally reserved for debugging and not for a release version. I am wondering if you are a "C-style" developer, which might be causing some of your angst.
Ummm... No. I've been a hard core C++ developer for 30+ years and have a 1.1M line personal code base. So it's safe to say I'm not a C style developer. I have my own test framework and my own asserts my own standard library and my own everything, so none of that would be applicable to me. My asserts are appropriately used for things that would represent coding errors, not input errors (obviously no one is 100% consistent in such a large code base.) And of course I can choose to have them on in release if I want, or have separate ones for release vs. debug.
I never use any form of code analysis tool, though I have tried a few in the past. Such tools, as you pointed out, merely throw up a voluminous amount of errors and warnings, most of which are meaningless. And I have never found such an issue that I would rewrite my code in such a fashion.
I have been coding for nearly 5 decades and if by that time you have not developed a clean, efficient style of development, you are not going to. And a code analysis tool will not help you much.
What code analysis tools find are those issues applied against the set of paradigms a the vendor of a particular tool want you to follow. Such paradigms are neither correct or incorrect. If you want to follow them that is perfectly fine.
However, most developers do their work from a very personal standpoint and take pride in their work from such a position. As a result, such development will often find the issues that you found with Visual Studio's Code Analyzer tool.
And again, mist such issues are meaningless.
There are some exceptions to this however where such tools demonstrate the more efficient method of developing your logic. However, a lot of this is all relative. For example, I still use ArrayLists quite heavily in my code. Why would I do this when it is already known that List<t> collections are more efficient as the following description from StackOverflow demonstrates?
> Yes, pretty much. List<t> is a generic class. It supports storing values of a specific type without casting to or from object (which would have incurred boxing/unboxing overhead when T is a value type in the ArrayList case). ArrayList simply stores object references. As a generic collection, List<t> implements the generic IEnumerable<t> interface and can be used easily in LINQ (without requiring any Cast or OfType call).
ArrayList belongs to the days that C# didn't have generics. It's deprecated in favor of List<t>. You shouldn't use ArrayList in new code that targets .NET >= 2.0 unless you have to interface with an old API that uses it.
Because whether you use an ArrayList or a List<t> is one, a personal preference, and two only efficient in the amount of data being processed. So for example, if I use an ArrayList to process 50 stored structures in a for-each loop, do you really think that by using a List<t> collection it will make such a process more efficient to the end user? Highly unlikely, since all such processes are done in milliseconds and people who insist that others follow the List<t> protocol when there is no need to are merely wasting everyone's time.
Of course, if you plan to process several thousand objects in such a loop than the use of the List<t> collection makes a
lot more sense.
But for me, the amount of data I process in an ArrayList is just as efficient as if I had used a List<t> collection type.
And finally, all of my code can be read and understood by a person less experienced than I than if I had coded it with modern or current standards that have added levels of such obscurity as to make most such such code rather arcane in my view.
Given this, then using a code analyzer serves its purpose if you are intent on developing using current paradigm approaches to your development. And in most such tools, you can turn off a lot of the rules they go by. However, this can be a lot of work and almost to the point of not making it worth the effort. And trying to enter the rules listing in Visual Studio 2019 to review the number of settings that should be able to modified appears to keep crashing the IDE.
Sr. Software Engineer
Black Falcon Software, Inc.
So I went back and figured I'd give it another try, just to be fair. I did ultimately find a legitimate though unlikely issue. But, I introduced a bad bug in the process of trying to get rid of warnings, and spent a couple hours trying to figure that out.
A lot of the raft of issues it was whining about were just the same ones over and over, because they were in templates and it would spit them out for each use of the offending bit of code. So it was somewhat easier to get rid of them than I thought initially. Though, it's annoying that you don't see the errors until someone uses the code, since it means constantly going back and having to tweak fundamental headers that cause big rebuilds. I have all of these collections set up to pre-instantiate and export for some common element types, but that doesn't seem to enough to make it complain.
So it's a bit of a tedious and time consuming process to deal with all of the warning i n those fundamental collection template classes.
Anything that is unrelated to elephants is irrelephant Anonymous - The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944 - Never argue with a fool. Onlookers may not be able to tell the difference. Mark Twain
Yep, a picture of person who can complete a sentence. Oi! these puns have felon hard times.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
Do the Thieves Guild first: serious sneak - and the Grey Fox cowl - really helps with the Dark Brotherhood questline. Kill anyone you want in front of the guards wearing it, take it off and they stop hunting you. It's also possible to keep the Boots of Springheel Jak, which helps a lot as well.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!