简体   繁体   English

IntelliJ,分析Scala代码

[英]IntelliJ, analyzing Scala code

When i am using IntelliJ to analyze ( Analyze->Inspect code ) my Java code, which happens to have an unused method, they are flagged. 当我使用IntelliJ分析(分析Analyze->Inspect code )我的Java代码(碰巧有未使用的方法)时,会对其进行标记。 This same behavior does not seem to be happening with Scala . Scala似乎没有发生这种相同的行为。

For instance, IntelliJ finds no issues with 例如, IntelliJ发现与

   object Main {

       def main(args: Array[String]) {
       }

       private def max(a: Int, b: Int) = {   // <---- unused
         if (a > b) a else b
       }
    }

在此处输入图片说明

Can i enable this (and other) checks somehow? 我可以以某种方式启用此(和其他)检查吗? What am i missing please? 我想念什么?

我认为IntelliJ不要将其设置为未使用是适当的,因为max方法被定义为公共方法。

As far as I can tell, the Scala plugin for IDEA doesn't have an inspection for unused methods (even private ones). 据我所知,用于IDEA的Scala插件没有检查未使用的方法(甚至是私有方法)。

For Java, IDEA has "Unused declaration": 对于Java,IDEA具有“未使用的声明”:

This inspection reports classes, methods or fields in the specified inspection scope that are not used or not reachable from entry points. 该检查报告指定检查范围内未使用或无法从入口点访问的类,方法或字段。

Unfortunately the only related inspection for Scala is "Unused Symbol." 不幸的是,与Scala唯一相关的检查是“未使用的符号”。

The only related issue I could find is SCL-3121 . 我可以找到的唯一相关问题是SCL-3121 You could add a feature request on the issue tracker for unused method highlighting. 您可以在问题跟踪器上添加功能请求,以突出显示未使用的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM