IDEA 编辑器发现重复的代码在文件中,会提示黄色警告 found duplicated code in this file finds duplicated code
具体如下图
这个警告不影响程序,但是看起来不太舒服
解决办法:
找到 Settings 、Editor 、 Inspections 、General、 Duplicated Code ,去掉后边的 √ 即可
IDEA 编辑器发现重复的代码在文件中,会提示黄色警告 found duplicated code in this file finds duplicated code具体如下图这个警告不影响程序,但是看起来不太舒服解决办法:找到 Settings 、Editor 、Inspections 、General、Duplicated Code ,去掉后边的 √ 即可...
可以识别交织的重复代码,生成新的函数。
本文具有很好的启发价值。
Programs often have a lot of
dupli
cat
ed
code
, which makes
both understanding and maintenance more dicult. This problem can be
alleviat
ed
by detecting
dupli
cat
ed
code
, extracting it into a separate new
proc
ed
ure, and replacing all the clones (the instances of the
dupli
cat
ed
code
) by calls to the new proc
ed
ure. This paper describes the design and
initial implementation of a tool that nds clones and displays them to
the programmer. The novel aspect of our approach is the use of program
dependence graphs (PDGs) and program slicing to nd isomorphic PDG
subgraphs that represent clones. The key benets of this approach are
that our tool can nd non-contiguous clones (clones whose components
do not occur as contiguous text in the program), clones in which match-
ing statements have been reorder
ed
, and clones that are intertwin
ed
with
each other. Furthermore, the clones that are found are likely to be mean-
ingful computations, and thus good candidates for extraction.
1、问题如下:
idea
不断的报出:
Found
dupli
cat
ed
code
in src/main/java/view/IatSpeechView.java less… (Ctrl+F1)
Inspection info: Finds
dupli
cat
ed
code
还有不断的波浪线,
但是代码运行正常。
2、解决方式:
原因是
idea
工具编译的原因,认为我们的代码有着大量代码的重复的地...
今天在写代码的时候,
idea
不断的报出:
Found
dupli
cat
ed
code
in service/src/main/java/com (Ctrl+F1) 还有不断的波浪线,
进行不断查找得出:这个是一个
idea
的编译的原因,也是
idea
的强大之处,应为我的代码是从其他的类中,copy出来的,有着大量代码的重复的地方,
idea
的意思是让你进行封装,可以直接调用.提高了代码的,可用性...
Found
dupli
cat
e
code
in 提示,因为项目中有重复的代码块。IntelliJ
IDEA
默认会打开该提示。
在配置中搜索
dupli
cat
e
code
,取消掉
Dupli
cat
ed
code
fragment后面的勾选
R
ed
undant boxing inside ‘Integer.valueOf(xx)’
解决办法:
改为Integer.parseInt(xx)即可。因为Integer.valueOf内部调用了parseInt,会提示多余的拆箱操作
‘xxx == null ? false : yyy’ can be simplifi
ed
to 'xxx!=null && yyy
解决办法:
按照提示修改即可。简化写法,原来写法比较啰嗦
‘OptionalInt.getAsInt()’ witho.
发现重复的代码这个提示真的很烦啊,我们怎么关闭他呢。
设置在这里:
Settings —>
Ed
itor —> Inspections —> General —>
Dupli
cat
ed
Code
对勾去掉,点击OK保存。
转载于:https://www.cnblogs.com/libra0920/p/6265203.htm...
提示有重复代码块
3、解决方式
File
→ Settings →
Ed
itor → Inspections→搜索 “
Dupli
cat
ed
Code
”→去掉
Dupli
cat
ed
Code
后面的勾选→Aapply→OK
Idea
提示 :found
dupli
cat
ed
code
in source
file
found
dupli
cat
ed
code
机智的
IDEA
大喊道,老大快看我发现了什么!重复的代码!
如图,
IDEA
黄色
波浪线提示在源码中发现重复的代码 ,
一个优秀的程序员不允许自己把同样的代码到处写,为了避免代码冗余,我们将此段代码抽象成方法或者放入工具类中,即可。
IDEA
代码抽象的好帮手。
···...