dead-code

find dead JavaScript code?

不想你离开。 提交于 2019-11-27 12:58:55
We are refactoring a legacy web app and as a result are "killing" quite a lot of JavaScript code but we're afraid of deleting what we think is dead code due to not being sure. Is there any tool / technique for positively identifying dead code in JavaScript? There's grep . Use it to find function calls. Suppose you have a method called dostuff() . Use grep -r "dostuff()" * --color on your project's root directory. Unless you find anything other than the definition, you can safely erase it. ack is also a notable alternative to grep . Without looking for anything too complex: JSLint (not really a

Dead code identification (C++)

与世无争的帅哥 提交于 2019-11-27 11:45:51
I have a large legacy C++ project compiled under Visual Studio 2008. I know there is a reasonably amount of 'dead' code that is not accessed anywhere -- methods that are not called, whole classes that are not used. I'm looking for a tool that will identify this by static analysis . This question: Dead code detection in legacy C/C++ project suggests using code coverage tools. This isn't an option as the test coverage just isn't high enough. It also mentions a -Wunreachable-code. option to gcc. I'd like something similar for Visual Studio. We already use the linker's /OPT:REF option to remove

How find all unused classes in Intellij Idea?

拟墨画扇 提交于 2019-11-27 04:10:34
问题 There is an inspection "Unused declaration" which can find all unused code in Intellij Idea. (see this question) But I want to find all unused classes, not methods, variables etc. Only classes. (it is difficult to find only classes in 3000 result list). How I can do that? 回答1: Press Ctrl + Shift + A (in Mac Command + Shift + A ) Enter "unused declar" Double-click on "Unused declaration" Settings will pop up Click on Java/Declaration redundancy/Unused declaration on the right bottom select "On

Unreachable code error vs. dead code warning in Java under Eclipse?

[亡魂溺海] 提交于 2019-11-27 00:40:07
Does anyone know why: public void foo() { System.out.println("Hello"); return; System.out.println("World!"); } Would be reported as an "unreachable error" under Eclipse, but public void foo() { System.out.println("Hello"); if(true) return; System.out.println("World!"); } Only triggers a "Dead code" warning? The only explanation I can think of is that the Java compiler only flags the first, and that some extra analysis in Eclipse figures out the second. However, if that is the case, why can't the Java compiler figure out this case at compile time? Wouldn't the Java compiler figure out at

How can you find unused functions in Python code?

左心房为你撑大大i 提交于 2019-11-26 22:01:47
So you've got some legacy code lying around in a fairly hefty project. How can you find and delete dead functions? I've seen these two references: Find unused code and Tool to find unused functions in php project , but they seem specific to C# and PHP, respectively. Is there a Python tool that'll help you find functions that aren't referenced anywhere else in the source code (notwithstanding reflection/etc.)? Jendrik In python you can find unused code by using dynamic or static code analyzers. Two examples for dynamic analyzers are coverage and figleaf . They have the drawback that you have to

Dead code detection in legacy C/C++ project [closed]

回眸只為那壹抹淺笑 提交于 2019-11-26 19:33:32
How would you go about dead code detection in C/C++ code? I have a pretty large code base to work with and at least 10-15% is dead code. Is there any Unix based tool to identify this areas? Some pieces of code still use a lot of preprocessor, can automated process handle that? You could use a code coverage analysis tool for this and look for unused spots in your code. A popular tool for the gcc toolchain is gcov, together with the graphical frontend lcov ( http://ltp.sourceforge.net/coverage/lcov.php ). If you use gcc, you can compile with gcov support, which is enabled by the '--coverage'

How to disable unused code warnings in Rust?

梦想的初衷 提交于 2019-11-26 18:39:44
struct SemanticDirection; fn main() {} warning: struct is never used: `SemanticDirection` --> src/main.rs:1:1 | 1 | struct SemanticDirection; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[warn(dead_code)] on by default I will turn these warnings back on for anything serious, but I am just tinkering with the language and this is driving me bats. I tried adding #[allow(dead_code)] to my code, but that did not work. Arjan You can either: Add an allow attribute on a struct, module, function, etc.: #[allow(dead_code)] struct SemanticDirection; Add a crate-level allow attribute ; notice the ! : #![allow

find dead JavaScript code?

亡梦爱人 提交于 2019-11-26 18:13:47
问题 We are refactoring a legacy web app and as a result are "killing" quite a lot of JavaScript code but we're afraid of deleting what we think is dead code due to not being sure. Is there any tool / technique for positively identifying dead code in JavaScript? 回答1: There's grep . Use it to find function calls. Suppose you have a method called dostuff() . Use grep -r "dostuff()" * --color on your project's root directory. Unless you find anything other than the definition, you can safely erase it

Dead code identification (C++)

亡梦爱人 提交于 2019-11-26 15:44:38
问题 I have a large legacy C++ project compiled under Visual Studio 2008. I know there is a reasonably amount of 'dead' code that is not accessed anywhere -- methods that are not called, whole classes that are not used. I'm looking for a tool that will identify this by static analysis . This question: Dead code detection in legacy C/C++ project suggests using code coverage tools. This isn't an option as the test coverage just isn't high enough. It also mentions a -Wunreachable-code. option to gcc.

Can branches with undefined behavior be assumed unreachable and optimized as dead code?

我怕爱的太早我们不能终老 提交于 2019-11-26 11:59:05
问题 Consider the following statement: *((char*)NULL) = 0; //undefined behavior It clearly invokes undefined behavior. Does the existence of such a statement in a given program mean that the whole program is undefined or that behavior only becomes undefined once control flow hits this statement? Would the following program be well-defined in case the user never enters the number 3 ? while (true) { int num = ReadNumberFromConsole(); if (num == 3) *((char*)NULL) = 0; //undefined behavior } Or is it