static-code-analysis

Lint-like program for Perl?

末鹿安然 提交于 2019-12-03 15:00:50
问题 I'm looking for a lint for Perl, something that would catch dead code and other potential problems. Any suggestions? I have use strict; use warnings; already but I'd like to have more. 回答1: Perl doesn't have a direct equivalent to lint. A large part of the reason for that is that Perl doesn't provide quite as many ways to hang yourself as C does. The basic version of "lint" for Perl is this: perl -Mstrict [-Mdiagnostics] -cw <file> This causes perl to compile (but not run) the specified file

Writing a R lint program

一曲冷凌霜 提交于 2019-12-03 11:35:57
问题 When I program in python, I find using pylint very useful. However, when I program in R, there is nothing comparable. As a small side project, I thought it would be fun to try and write a small lint program. Nothing too fancy, something along the lines of: Making sure function names are camel case Average function length Detecting unused variables Spacing. For example, function(x=1, y=2) instead of function(x=1,y=2) However, I'm unsure of how to get started (I have started to look through the

How do I download and install lint?

我是研究僧i 提交于 2019-12-03 06:55:37
问题 Does anyone know how to obtain lint for Mac, Windows, and Linux? sudo port install lint can't find it. 回答1: From the splint FAQ: Splint supports most, but not all, of the C99 extensions to the ANSI C. This implies that splint is alas not the same as lint. I've had personal experience with running splint on pieces of code like this: for (int i; i < 100; i++) /* Run code */ As declaration of a variable inside the for loop header is not permitted until C99, like in this example, splint will

Rulesets for cppcheck

社会主义新天地 提交于 2019-12-03 06:30:56
问题 Cppcheck allows you to create your own rules files, but I don't know how much of cppcheck's functionality is exposed. Is anyone working on a set that would enforce JSF or MISRA rules? 回答1: You won't be able to implement all MISRA/JSF rules and directives as cppcheck rules, mostly only the straightforward ones restricting certain C language features and constructions or that are style-related (some that come to mind: spaces before/after ./->, # of arguments on a single line, use of unions to

Automated docstring and comments spell check

Deadly 提交于 2019-12-03 01:20:35
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://stackoverflow.com/questions/2151300/whats-the-best-way-to-spell-check-python-source-code topic, now I know

Rulesets for cppcheck

末鹿安然 提交于 2019-12-02 20:11:04
Cppcheck allows you to create your own rules files, but I don't know how much of cppcheck's functionality is exposed. Is anyone working on a set that would enforce JSF or MISRA rules? johnwait You won't be able to implement all MISRA/JSF rules and directives as cppcheck rules, mostly only the straightforward ones restricting certain C language features and constructions or that are style-related (some that come to mind: spaces before/after ./->, # of arguments on a single line, use of unions to provide different methods of accessing memory, presence of unsigned/signed before char, etc). User

Code Metrics Analysis for Unmanaged C++ Code [closed]

倾然丶 夕夏残阳落幕 提交于 2019-12-01 03:11:14
Does anyone know of a free tool, similar to what is built into Visual Studio 2010 for managed code, that can do analysis of unmanaged, MFC C++ code and give metrics (lines of code, dependency or coupling, etc)? I've been searching on Google for awhile, but really haven't been able to find anything that works. Thanks a ton! Source Monitor is a good free tool tool for code metrics such as LoC and complexity and also produces kiviat graphs. But it does not have any depedency or coupling metrics. Our SourceMeter tool can analyze your Visual C++ project and provide you all the information you asked

Code Metrics Analysis for Unmanaged C++ Code [closed]

天涯浪子 提交于 2019-11-30 23:13:42
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . Does anyone know of a free tool, similar to what is built into Visual Studio 2010 for managed code, that can do analysis of unmanaged, MFC C++ code and give metrics (lines of code, dependency or coupling, etc)? I've been searching on Google for awhile, but really haven't been able to find anything that works.

How to make SonarQube module analyze the project only once when sonar analysis is bound to maven lifecycle in a multi-module project?

白昼怎懂夜的黑 提交于 2019-11-29 11:01:43
What I am trying to achieve is integrate SonarQube analysis into the build process, so that whenever mvn clean install is run, the code is analyzed with SonarQube. We want to use it for local analysis and also for build on Jenkins. If new issues are found, than the build should fail (we want to use build breaker plugin for that). This way the developer would know that by his code his is going to introduce new issues, and will have to fix them for the build to work. When I run mvn sonar:sonar , the analysis takes 30 seconds, which is OK. However, the problem occurs when I am trying to bind

Unintentional trailing comma that creates a tuple

好久不见. 提交于 2019-11-29 10:05:33
In Python, leaving a trailing comma like this is, of course, not a SyntaxError : In [1]: x = 1 , In [2]: x Out[2]: (1,) In [3]: type(x) Out[3]: tuple But, at the same time, if the trailing comma was put accidentally , it may be difficult to catch this kind of a "problem", especially for Python newcomers. I am thinking if we can catch this kind of a "problem" early , statically, with the help of PyCharm smart code quality control features; mypy , pylint or flake8 static code analysis tools. Or, another idea would be to restrict/highlight creating one item tuples implicitly without parenthesis .