私はSonarとWeld/CDIの両方に不慣れです。Weld/CDIを使用したLCOM4の分析結果についてさらにアドバイスをお願いします。まず、次のように単純なJavaクラスを作成します。
- - - - - - -ソース - - - - - - - -
interface MyInterface1 {
String getName();
void setName(String name);
}
interface MyInterface2 extends MyInterface1 {
String getPhone();
void setPhone();
}
public interface MyPublishedInterface extend MyInterface1, MyInterface2 {
//There is no any definition, it just a collected capabilities
//which will be published to other package. Some capabilities
//may be hidden and use internally.
}
abstract class MyBean1 implements MyInterface1 {
private String name;
@Override
public String getName() {
return this.name;
}
@Override
public void setName(String theName) {
this.name = theName;
}
}
abstract class MyBean2 extends MyBean1 implements MyInterface2 {
private String phone;
@Override
public String getPhone() {
return this.phone;
}
@Override
public void setPhone(String thePhone) {
this.phone= thePhone;
}
}
public class MyPublishedBean extends MyBean2 implements MyPublishedInterface {
//There is no any coding, it just a collected capabilities
//which will be published to other package. Some capabilities
//may be hidden and use internally.
}
@Named
@RequestScope
public class MyBackingBean {
@Inject
private MyPublishedInterface myPublishedInterface;
//-----the business method, setter and getter here.
}
- - - - - - -ソース - - - - - - - -
Sonarで分析した後、MyPublishedBeanのLCOM4>1は次のように報告されます。
- getPhone()Ljava / lang / String;
- setName(Ljava / lang / String;)V
- setPhone(Ljava / lang / String;)V
- getName()Ljava / lang / String;
以前は、すべてのメソッドを「最終」メソッドとしてマークしていましたが、LCOM4については何も言及されていません。とにかく、私のクラスにはfinalメソッドが含まれているため、システムはUnproxyableに関する例外を表示します。「ファイナル」を削除しましたが、LCOM4の問題に直面しました。
Sonar、Weld / CDI、クラス/インターフェイスデザイン、またはそれらすべてについて混乱しているかどうかはわかりません。さらにアドバイスをお願いします。