Bug 483995 - [cleanup] New cleanup suggestion: "Use modifier 'static' for methods where possible"
Summary: [cleanup] New cleanup suggestion: "Use modifier 'static' for methods where po...
Status: CLOSED DUPLICATE of bug 10605
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.6   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-09 05:48 EST by Luke Hutchison CLA
Modified: 2015-12-18 10:11 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luke Hutchison CLA 2015-12-09 05:48:02 EST
Methods that do not access fields should be static where possible, as this visually signifies that the method does not access fields of the class it is defined within, and encourages a more functional style of programming.

It would be great to have a cleanup rule that checks if a method accesses fields, and if not, adds the static modifier to the method.

This should also probably be added as a quick fix action for qualifying methods.
Comment 1 Jay Arthanareeswaran CLA 2015-12-09 08:53:38 EST
Moving to UI
Comment 2 Timo Kinnunen CLA 2015-12-09 16:02:07 EST
A quick fix is already available after an optional warning for "Method can be static" or "Method can potentially be static" in compiler settings is enabled. Admittedly these quickfixes aren't at all discoverable when the warnings are not enabled. Perhaps this should be improved somehow..
Comment 3 Noopur Gupta CLA 2015-12-18 10:11:34 EST

*** This bug has been marked as a duplicate of bug 10605 ***