Remove unused code from ee/lib/code_suggestions/programming_language.rb
CodeSuggestions::ProgrammingLanguage class contains some unnecessary code:
-
comment_format
is public although not used/needed outside of this class (!132659 (diffs, comment 1583710109)) - because this method is not needed outside, it should be private - LANGUAGE_COMMENT_FORMATS contains both
single
andsingle_regexp
values (currently only for VBScript) although both values can never be used (related to !132659 (comment 1583710097)) - because only one of values is always used, it should not be necessary to have both
The only reason why above changes were added is because .current_format[:single]
is used from tests (for example !132659 (diffs).
I think that:
- the library should contain only code which is really used, otherwise it causes extra maintenance and confusion for other developers who will wonder why an unused code is present
- usage from specs is not a reason to add additional code - specs should test the behavior of the class w/o additional changes in the class
I think it would be better to just define a set of comment samples in a shared context which can be then reused in various tests, a simple test can assure that all comment prefixes are covered (so it doesn't get out of sync with LANGUAGE_COMMENT_FORMATS
)
The following discussion from !132659 (merged) should be addressed:
-
@jprovaznik started a discussion: (+5 comments) Why are we defining also
single
ifsingle_regexp
is defined? IOW when is thissingle
value used for DEFAULT_FORMAT?