static-analysis

generic code duplication detection tool

强颜欢笑 提交于 2019-12-03 04:40:46
I'm looking for a code duplication tool that is language agnostic. It's easy to find language specific code duplication tools (for Java, C, PHP, ...), but I'd like to run some code duplication analysis on a templates in a custom syntax. I don't care about advanced parsing of the syntax, just straight line based raw string comparison is fine. Whitespace insensitive matching would be a plus, but not required. (It's not that hard to normalize/eliminate whitespace myself.) Does anybody know a tool that can be (mis)used for something like this? Thanks. Doon Have a look Simian , you can use it for

javax.annotation: @Nullable vs @CheckForNull

筅森魡賤 提交于 2019-12-03 04:06:17
问题 What is the difference between the two? Both seem to mean that the value may be null and should be dealt with accordingly i.e. checked for null. Update: The two annotations above are part of JSR-305/FindBugs: http://findbugs.sourceforge.net/manual/annotations.html 回答1: I think it is pretty clear from the link you added: if you use @CheckForNull and the code that uses the value does not check for null , FindBugs will show it as an error. FindBugs will ignore @Nullable . In practice this

Best way in MySQL or Rails to get AVG per day within a specific date range

断了今生、忘了曾经 提交于 2019-12-03 03:45:37
I'm trying to make a graph in Rails, for example the avg sales amount per day for each day in a given date range Say I have a products_sold model which has a "sales_price" float attribute. But if a specific day has no sales (e.g none in the model/db), I want to return simply 0. What's the best way in MySQL/Rails to get this done? I know I can do something like this: ( This SQL query might be the completely wrong way to get what I'm wanting too ) SELECT avg(sales_price) AS avg, DATE_FORMAT(created_at, '%m-%d-%Y') AS date FROM products_sold WHERE merchant_id = 1 GROUP BY date; And get results

Is there a tool to validate an Azure DevOps Pipeline locally?

不羁岁月 提交于 2019-12-03 00:52:51
When making changes to YAML-defined Azure DevOps Pipelines, it can be quite tedious to push changes to a branch just to see the build fail with a parsing error (valid YAML, but invalid pipeline definition) and then try to trial-and-error fix the problem. It would be nice if the feedback loop could be made shorter, by analyzing and validating the pipeline definition locally; basically a linter with knowledge about the various resources etc that can be defined in an Azure pipline. However, I haven't been able to find any tool that does this. Is there such a tool somewhere? Jamie You can run the

Import order coding standard

半城伤御伤魂 提交于 2019-12-03 00:20:42
问题 PEP8 suggests that: Imports should be grouped in the following order: standard library imports related third party imports local application/library specific imports You should put a blank line between each group of imports. Is there a way to check if the standard is violated anywhere in the package using static code analysis tools, like pylint , pyflakes , pychecker , pep8 ? Example of violation: from my_package import my_module from django.db import models import os Correct way to import:

Break down C++ code size

女生的网名这么多〃 提交于 2019-12-02 23:41:51
I'm looking for a nice Stack Overflow-style answer to the first question in the old blog post C++ Code Size , which I'll repeat below: I’d really like some tool (ideally, g++ based) that shows me what parts of compiled/linked code are generated from what parts of C++ source code. For instance, to see whether a particular template is being instantiated for hundreds of different types (fixable via a template specialization) or whether code is being inlined excessively, or whether particular functions are larger than expected. nategoose It does seem like something like this should exist, but I

Is there a need for a “use strict” Python compiler?

女生的网名这么多〃 提交于 2019-12-02 23:33:46
There exist static analysis tools for Python , but compile time checks tend to be diametrically opposed to the run-time binding philosophy that Python embraces. It's possible to wrap the standard Python interpreter with a static analysis tool to enforce some " use strict "-like constraints, but we don't see any widespread adoption of such a thing. Is there something about Python that makes "use strict" behavior unnecessary or especially undesirable? Alternatively, is the "use strict" behavior unnecessary in Perl, despite its widespread adoption? Note: By "necessary" I mean "practically

Explain System.Diagnostics.CodeAnalysis.SuppressMessage

旧巷老猫 提交于 2019-12-02 22:57:18
I have this kind of code in some applications (from microsoft) [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "CounterClockwise", Scope = "member", Target = "ScePhotoViewer.PhotoDisplayControl.#RotatePhotoCounterClockwiseCommand" )] Can anyone explain me this ? Is there any blog explaining how to use it, the real benefits... Thanks Jonathan This attribute is used by Team Foundation Server 's (TFS) code analysis functionality to exclude code fragments that would otherwise trigger warnings. You can safely

Static call graph generation for the Linux kernel

无人久伴 提交于 2019-12-02 22:48:02
I'm looking for a tool to statically generate a call graph of the Linux kernel (for a given kernel configuration). The generated call graph should be "complete", in the sense that all calls are included, including potential indirect ones which we can assume are only done through the use of function pointers in the case of the Linux kernel. For instance, this could be done by analyzing the function pointer types: this approach would lead to superfluous edges in the graph, but that's ok for me. ncc seems to implement this idea, however I didn't succeed in making it work on the 3.0 kernel. Any

Tool to find all unused Code

会有一股神秘感。 提交于 2019-12-02 22:33:04
I need a tool I can run that will show me a list of unused methods, variables, properties, and classes. CSS classes would be an added bonus. I heard FXCop can do this? or NDepend or something? Look at ReSharper . Code Analysis in VSTS will generate warnings about this during the build process. You can set it up to treat Warnings As Errors. You can use ReSharper to find unused code and Dust-Me Selectors to find unused CSS. The tool NDepend can help find unused code in a .NET code base. Disclaimer: I am one of the developer of this tool. NDepend proposes to write Code Rule over LINQ Query