Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LinterTrait, which provides the common functions for both SingleRuleLinter and HHClientLinter #387

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Atry
Copy link
Contributor

@Atry Atry commented Nov 9, 2021

No description provided.

@Atry Atry changed the title Add LinterTrait, which provide the common functions for SingleRuleLinter and HHClientLinter Add LinterTrait, which provide the common functions for both SingleRuleLinter and HHClientLinter Nov 9, 2021
@Atry Atry force-pushed the linter-trait-2 branch 3 times, most recently from 34f5476 to b19848d Compare November 10, 2021 01:34
@Atry Atry changed the title Add LinterTrait, which provide the common functions for both SingleRuleLinter and HHClientLinter Add LinterTrait, which provides the common functions for both SingleRuleLinter and HHClientLinter Nov 10, 2021
Copy link
Contributor

@fredemmott fredemmott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like it should be an abstract class instead: every linter should use this trait and implement the interface.

src/Linters/LinterTrait.hack Outdated Show resolved Hide resolved
@Atry
Copy link
Contributor Author

Atry commented Nov 10, 2021

This feels like it should be an abstract class instead: every linter should use this trait and implement the interface.

We can turn this trait into an abstract class for now. But it would become a problem if we also create another abstract class for LintRule, because SingleRuleLinter cannot extend both abstract classes.

@fredemmott
Copy link
Contributor

Yeah :( I suspect we'll revisit this once traits are reworked and formalize. We might end up doing base classes and traits - base classes for devx, where the base classes always pull in the traits - but as multiple inheritance isn't supported, SingleRuleLinter would have to use at least one of the traits directly

@Atry
Copy link
Contributor Author

Atry commented Nov 10, 2021

Yeah :( I suspect we'll revisit this once traits are reworked and formalize. We might end up doing base classes and traits - base classes for devx, where the base classes always pull in the traits - but as multiple inheritance isn't supported, SingleRuleLinter would have to use at least one of the traits directly

By the way, I updated this PR to introduce the BaseLinter as an abstract class, but I feel we could have a better design than this.

I think the best design in Hack, considering the restrictions in the object model, is to minimize the interfaces and to eliminate the demand of sharing implementation between class instances. We can then move helper methods into namespaces as top-level free functions. Each time we want to add a helper, we add it as a free function. Each time we need new methods in the interfaces, we create a new interface containing the new methods instead of changing existing interfaces.

@fredemmott
Copy link
Contributor

Each time we need new methods in the interfaces, we create a new interface containing the new methods instead of changing existing interfaces.

If there's a semantic separation, i agree with this, but not purely as a BC mechanism; large sets of related hierarchies really hurt developer experience. BC vs devx is a tradeoff.

@facebook-github-bot
Copy link

Hi @Atry!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants