|
Sander Rossel wrote: ERROR! btnSave_Click is not according to conventions
On the plus side, anyone reading the code knows immediately that the function is an event handler, which control it's for, and what event it handles.
|
|
|
|
|
I just did an analysis on a piece of WPF code I wrote recently (which runs fine, BTW), and it found two variables that weren't used (which I had already pragama'd around, and seven instances of CA2214 (Do not call overridable methods in constructors), which involved having forms derived from a base form class that implemented INotifyPropertyChanged . I'm not changing my code...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I have a big codebase and think CA helps a lot! If you don't like the default rules set - make your own or customize it. I normally would go for local supressions directly on the code in Question - but for your case a global supression could do (or in Project-Settings). I think it's not OK to say the CA "sucks" - if you have special needs customize it - you can, and it's not difficult.
|
|
|
|
|
A global suppression of fundamental checks would do no good. Then I would never see any actual legitimate problems of that type, which would make it not worth doing to begin with.
Explorans limites defectum
|
|
|
|
|
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.
GitHub - DeanRoddey/CIDLib: The CIDLib general purpose C++ development environment[^]
The issue is writing less readable and maintainable code just to make the analyzer happy. That is likely to cause more problems than the few things it actually manages to catch.
Explorans limites defectum
|
|
|
|
|
You mentioned having your own "standard library", perhaps you have some conflicts that can be resolved using namespaces?
|
|
|
|
|
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.
Steve Naidamast
Sr. Software Engineer
Black Falcon Software, Inc.
blackfalconsoftware@outlook.com
|
|
|
|
|
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.
Explorans limites defectum
|
|
|
|
|
It is apparent.
“The palest ink is better than the best memory.” - Chinese Proverb
|
|
|
|
|
Is a police mugshot just a cellfie?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I guess you could say that every criminal gets captured twice.
|
|
|
|
|
Three times: Left side, Center and Right side!
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
|
|
|
|
|
I hear they also get taken from behind
|
|
|
|
|
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
|
|
|
|
|
jeron1 wrote: a picture of person who can completestart a sentence.
FTFY
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Those who mug cameras are doomed to mug for the camera.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
No! All wrong!
A police mugshot is something that happens during a shoot-out at Starbucks!
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
or simply that extra dose of espresso.
|
|
|
|
|
...an article gets updated and I don't realize / remember I've read it before. So I read it with interest and I'm thinking, wow, this is really interesting and I think I'll leave a comment...
...only to realize once I look at the comments that I've already read it and commented on it!
Such was the case this morning with Some Fun with Dynamic Methods and CLR (Part 2)[^]
I think my brain needs an augment.
|
|
|
|
|
Look at the bright side: As the condition progresses, you meet more interesting new people, watch more new movies, read new books and articles. Every day.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
I don't have to wait 24 hours, I'm enjoying that comment every 5 minutes!
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
|
|
|
|
|
|
As I get older I'm finding that having multiple personalities and memory lose has allowed me to meet new and interesting people also.
They call me different but the truth is they're all the same!
JaxCoder.com
|
|
|
|
|
Mike Hankey wrote: having multiple personalities
Yes, you meet yourself both coming and going.
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|