2023-05-03 11:06:20 +02:00
== Why is this an issue?
2021-06-08 14:23:48 +02:00
Having a duplication between a field name and a method name is confusing, misleading, and probably an indication that the field name should be updated to be more meaningful.
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2021-06-08 14:23:48 +02:00
2022-02-04 17:28:24 +01:00
[source,text]
2021-06-08 14:23:48 +02:00
----
public class Foo {
public int sum; // Noncompliant, matching sum() method name
public int sum() {...}
}
----
2023-05-03 11:06:20 +02:00
=== Compliant solution
2021-06-08 14:23:48 +02:00
2022-02-04 17:28:24 +01:00
[source,text]
2021-06-08 14:23:48 +02:00
----
public class Foo {
public int sumTotal; // Compliant
public int sum() {...}
}
----