fb-contrib icon indicating copy to clipboard operation
fb-contrib copied to clipboard

CNC_COLLECTION_NAMING_CONFUSION should match entire words only

Open sabberworm opened this issue 5 years ago • 1 comments

I’ve had some false positives with CNC_COLLECTION_NAMING_CONFUSION when using names like offset, asset for collections that were not sets.

I think CNC_COLLECTION_NAMING_CONFUSION should only match if the magic words it searches for (map/set/list/queue) are single words on camel/snake case boundaries.

For example, the following should match:

  • map
  • Map
  • MAP
  • asSet
  • SOME_SET

While these shouldn’t:

  • asset
  • spielbergsEt
  • runNmap
  • COMMAND_NMAP
  • TAG_NAMES_LI_ST

Also, I’m not sure why you’re excluding toset from the check. Shouldn’t a method named toSet usually return a set?

I suggest you also include checks for the words deque and stack (which should match the java.util.Deque interface).

sabberworm avatar Aug 03 '20 13:08 sabberworm

better to avoid deque in naming, same problem https://github.com/checkstyle/checkstyle/pull/12855#issuecomment-1474846212

romani avatar Jul 03 '23 18:07 romani