static-analysis

generic code duplication detection tool

久未见 提交于 2019-12-20 17:16:09
问题 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

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

最后都变了- 提交于 2019-12-20 16:25:38
问题 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

How to exclude private members from StyleCop rule SA1600

纵然是瞬间 提交于 2019-12-20 16:16:22
问题 Does anyone know how to change the StyleCop rule SA1600 that says elements must be documented so that it only applies to properties and not to private members? Our ORM (DevExpress XPO) requires that you have private members for all public properties (because you have to call a function in the setter to persist it as well as storing it in the private member), and commenting both the public property and the private member with the same thing is killing me considering that some of the tables

Break down C++ code size

我与影子孤独终老i 提交于 2019-12-20 10:56:02
问题 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

Tool to automatically rewrite a bash script with proper quoting?

北城余情 提交于 2019-12-20 09:47:38
问题 I'm contemplating to make all bash scripts of a large codebase shellcheck compliant, but the task is overwhelming, because too many developers have historically ignored rule number one of all shell scripting: always use quotes. It would be helpful if there was a tool that could fix at least the quoting. I would then be able to fix the rest by hand. My regex didn't cut it, because only variables not already in a string must be quoted. Sample input: echo "Removing $a ${b} $(c $(c)) `d $d` ${10}

Are there any tools for performing static analysis of Scala code? [closed]

谁说胖子不能爱 提交于 2019-12-20 08:27:45
问题 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 . Are there any tools for performing static analysis of Scala code, similar to FindBugs and PMD for Java or Splint for C/C++? I know that FindBugs works on the bytecode produced by compiling Java, so I'm curious as to how it would work on Scala. Google searches (as of 27 October 2009) reveal very little. Google

Roslyn / Find References - Can't properly load Workspace

守給你的承諾、 提交于 2019-12-19 06:44:22
问题 I'm trying to write some code to find all method invocations of any given method as I am looking to create an open source UML Sequence Diagramming tool. I'm having trouble, however, getting past the first few lines of code :/ The API appears to have changed drastically and I can't seem to infer proper usage by looking at the code. When I do: var workspace = new CustomWorkspace(); string solutionPath = @"C:\Workspace\RoslynTest\RoslynTest.sln"; var solution = workspace.CurrentSolution; I find

tracking uninitialized static variables

牧云@^-^@ 提交于 2019-12-19 06:26:29
问题 I need to debug an ugly and huge math C library, probably once produced by f2c. The code is abusing local static variables, and unfortunately somewhere it seems to exploit the fact that these are automatically initialized to 0. If its entry function is called with the same input twice, it is giving different results. If I unload the library and reload it again, it works correctly. It needs to be fast, so I would like to get rid of the load/unload. My question is that how to uncover these

Replacing arrays access variables with the right integer type

白昼怎懂夜的黑 提交于 2019-12-19 03:59:44
问题 I've had a habit of using int to access arrays (especially in for loops); however I recently discovered that I may have been "doing-it-all-wrong" and my x86 system kept hiding the truth from me. It turns out that int is fine when sizeof(size_t) == sizeof(int) but when used on a system where sizeof(size_t) > sizeof(int) , it causes an additional mov instruction. size_t and ptrdiff_t seem to be the optimal way on the systems I've tested, requiring no additional mov . Here is a shortened example

Extract information on usage of functions and packages in R scripts

人走茶凉 提交于 2019-12-19 02:32:35
问题 What would be a proper way to extract function calls and their occuring line in one or more R scripts? Is there a parsing base function or package that allows me to do this or should I build a solution with regular expressions? For example: function_calls("project1/exploratory_analysis.R") should output a dataframe like: ## function line filename ## 1 tapply 35 exploratory_analysis.R ## 2 qplot 80 exploratory_analysis.R What I want to achieve finally is to build a reverse index of function