Open ericvergnaud opened 7 months ago
Why not just making class Fixer(Linter):
?
Why not just making
class Fixer(Linter):
?
I guess because Fixer is not a specialization of Linter ? There's no hard rule for this, but in this particular case, I think that composition is more appropriate than inheritance. I might be biased by my single-inheritance + multiple interfaces background. In Java, AdviceHandler interface would extend Linter and Fixer, and Fixer interface would certainly not inherit from Linter interface.
@ericvergnaud we still need to see if we can change a portion of the code without reconstructing the entire syntax tree (think of comments, formatting, etc...), which means that Fixer
interface is not final and may change. That may require Fixer
to couple on a certain message codes.
That may require Fixer to couple on a certain message codes
Not sure I follow, can you provide an example ?
Is there an existing issue for this?
Problem statement
Code migration agents such as
SparkSql
rely on multiple inheritence fromLinter
andFixer
, which are separate classes. This separation is artificial. In practice, you can't have aFixer
without aDetector
(currently namedLinter
). As a result, theLanguages
class maintains 2 separate lists for linters and fixers, and holds the responsibility of ensuring there exists aFixer
for eachLinter
, which it should not hold.Proposed Solution
Create an AdviceHandler class that inherits from
Linter
andFixer
and have code migration agents inherit from it.Additional Context
No response