code-analysis

VS2010 code analysis. Suppress message CA1051:DoNotDeclareVisibleInstanceFields for all class members

依然范特西╮ 提交于 2019-12-04 09:04:50
I have a class like this one: public class Foo { public readonly int A = 1; public readonly int B = 2; } When I run VS2010 built in Code Analysis tool, I get 2 identical warnings: that ' field '...' is visible outside of its declaring type, change its accessibility to private and add a property, with the same accessibility as the field has currently, to provide access to it '. I want to suppress this warning for all fields in my class Foo , but I don't want to mark every field with SuppressMessage attribute like this: public class Foo { [SuppressMessage("Microsoft.Design", "CA1051

Automated docstring and comments spell check

丶灬走出姿态 提交于 2019-12-04 08:57:53
问题 Consider the following sample code: # -*- coding: utf-8 -*- """Test module.""" def test(): """Tets function""" return 10 pylint gives it 10 of 10, flake8 doesn't find any warnings: $ pylint test.py ... Global evaluation ----------------- Your code has been rated at 10.00/10 ... $ flake8 test.py $ But, as you may see, there is a typo in the test function's docstring. And, your editor would probably highlight it automagically, for example, here's how Pycharm does it: Thanks to the https:/

Error in FxCop Phoenix analysis engine

≡放荡痞女 提交于 2019-12-04 07:33:24
So I'm trying to run a bunch of rules which are defined in a RuleSet. The RuleSet file is actually generated using Sonarqube - I've selected absolutely all rules in there, including the FxCop, ReSharper and StyleCop rules. I'm kicking off FxCop like this: C:/FxCop/FxCopCmd.exe /file:C:\TestProject\bin\TestProject.dll /ruleset:=C:\TestProject\testproject.ruleset /out:C:\TestProject\fxcop-report.xml /outxsl:none /forceoutput /searchgac /aspnet It starts correctly, but I get the following message: Initializing Introspection engine... Analyzing... Initializing Phoenix engine... Analyzing...

What tools do you use for static code analysis? [closed]

笑着哭i 提交于 2019-12-04 07:31:45
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . This question on Cyclomatic Complexity made me think more about static code analysis. Analyzing code complexity and consistency is occasionally useful, and I'd like to start doing it more. What tools do you recommend (per language) for such analysis? Wikipedia has a large

Test case for Insertion Sort, MergeSort and Quick Sort

无人久伴 提交于 2019-12-04 07:14:33
I have implemented (in Java) Insertion Sort, MergeSort, ModifiedMergeSort and Quick Sort: ModifiedMergeSort has a variable for the "bound" of elements. When the elements to be sorted are less than or equal to "bound" then use Insertion Sort to sort them. How come Version 1 is better than Versions 3, 4 and 5? Are the results for Versions 2 and 6 realistic? Here is my results (In Milliseconds): Version 1 - Insertion Sort: Run-Times over 50 test runs Input Size Best-Case Worst-Case Average-Case N = 10000 14 19 14.96 N = 20000 59 60 59.3 N = 40000 234 277 243.1 Version 2 - Merge Sort: Run-Times

Code analysis comes back with suggestion about not using “out” parameters

戏子无情 提交于 2019-12-04 07:07:25
I ran the VS 2008 code analysis tool against an object I created and received the following suggestion ... Warning 147 CA1021 : Microsoft.Design : Consider a design that does not require that 'returnValue' be an out parameter. I find "out" parameters rather useful and didn't realize that they were considered as a frowned upon design practice. I wanted to know if someone could shed some light on the reason that I received this Warning? If it is bad practice? why? and what would be good practice? I appreciate any advice. Every Code Analysis warning has associated documentation that you can

Parsing Classes, Functions and Arguments in PHP

懵懂的女人 提交于 2019-12-04 06:32:15
I want to create a function which receives a single argument that holds the path to a PHP file and then parses the given file and returns something like this: class NameOfTheClass function Method1($arg1, $arg2, $arg2) private function Method2($arg1, $arg2, $arg2) public function Method2($arg1, $arg2, $arg2) abstract class AnotherClass function Method1($arg1, $arg2, $arg2) private function Method2($arg1, $arg2, $arg2) public function Method2($arg1, $arg2, $arg2) function SomeFunction($arg1, $arg2, $arg3) This function should return all the classes, methods and function that exist in the given

Show Code Analysis warnings in VSTS

元气小坏坏 提交于 2019-12-04 05:53:05
问题 I've setup Static Code Analysis on my Visual Studio Team Services builds. I'm using the "MSBuild" build step for my solution and in the build logs it shows 999+ lines that start with ##[warning] : 2017-11-09T13:52:34.7970784Z ##[warning]myfilename.cs(753,17): Warning CA2200: Re-throwing caught exception changes stack information. When building with "system.debug" set to true, we also see that vso parses these warnings, and 999+ lines in the log show up like this: 2017-11-15T12:30:40.1964968Z

Is there a Delphi library which returns all effective source paths for a project?

怎甘沉沦 提交于 2019-12-04 05:05:51
For static code analysis tools, it is necessary to know all effective source paths for a given Delphi project, which are defined on project level and in the global IDE configuration. Is there a Delphi library which can collect this kind of project information? As far as I know, the registry settings for the Delphi IDE can be in different places, to support multiple configurations. But for a given combination of the IDE registry location and a project file, it should be possible to collect the source paths. Edit : Another solution is to use the --depends switch. This will cause dcc32.exe to

How can the cyclomatic complexity be 27 in a method with 13 event handler subscriptions?

ぐ巨炮叔叔 提交于 2019-12-04 04:49:36
We have this code, sortof: private void InitializeEvents() { this.Event1 += (s,e) => { }; this.Event2 += (s,e) => { }; this.Event3 += (s,e) => { }; this.Event4 += (s,e) => { }; this.Event5 += (s,e) => { }; this.Event6 += (s,e) => { }; this.Event7 += (s,e) => { }; this.Event8 += (s,e) => { }; this.Event9 += (s,e) => { }; this.Event10 += (s,e) => { }; this.Event11 += (s,e) => { }; this.Event12 += (s,e) => { }; this.Event13 += (s,e) => { }; } Code analysis in VS10 Ultimate says "cyclomatic complexity of 27". Removing one of the lines makes the cyclomatic complexity 25. There's no branching going