Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6073627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:17:30+00:00 2026-05-23T10:17:30+00:00

I’m new for both Sonar and Weld/CDI. I would like your help to advise

  • 0

I’m new for both Sonar and Weld/CDI. I would like your help to advise further about the LCOM4 analyzed result with Weld/CDI. Firstly I create a simple java class as the following: –

————-Source—————

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.
}

————-Source—————

After I’ve analyzed with the Sonar, it reports that the MyPublishedBean has a LCOM4>1 as

  1. getPhone()Ljava/lang/String;
  2. setName(Ljava/lang/String;)V
  3. setPhone(Ljava/lang/String;)V
  4. getName()Ljava/lang/String;

Previously I used to mark all method to be a “final” method, there is no any mentions about the LCOM4. Anyhow the system shows me the exception about Unproxyable since my class contains a final method. I had removed the “final”, I faced the LCOM4 issue.

I’m not sure if I’m confused about Sonar, Weld/CDI, the class/interface design or all of them. Could you please help to advise further?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:17:30+00:00Added an answer on May 23, 2026 at 10:17 am

    The Sonar docs explain LCOM4 quite well. The results you see are completely correct given the example you gave here.

    These interfaces look like they are merely data holders with no logic. A bean with just getters and setters for properties will fully expect to have an LCOM value equal to the number of properties in the bean. LCOM4 is a metric meant to measure the cohesion of logic in a class. The logic of a pure data bean is only that the data is in some way related to each other. LCOM4 is therefore in this case an incorrect and misleading metric to use.

    LCOM4 should also be completely independent of whether your methods are final or not.

    Please note that LCOM4 > 1 indicates a suspect class. It does not mean that the class is wrong and should not be used to flag the class as bad. Once you find that the suspect class is okay, it is best to remove that class in some way from the metric (to avoid you building up a long list of warnings that you know should be ignored).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I would like to count the length of a string with PHP. The string
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.