-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Allow app check code for deprecated classes #16935
Allow app check code for deprecated classes #16935
Conversation
Awesome work. |
Needs rebase |
@nickvergessen please rebase an let's move this in - THX |
Btw, does anyone know something that got deprecated in the last 21days? |
faef8de
to
ee7dd54
Compare
Not that I'm aware of |
Rebased and added the open task as todo. Should be okay to merge, it doesn't catch everything, but at least static methods are done. |
); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) { | ||
$appId = $input->getArgument('app-id'); | ||
$codeChecker = new \OC\App\CodeChecker(); | ||
if ($input->getOption('deprecated')) { | ||
$codeChecker = new DeprecationCodeChecker(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would highly recommend use of the Decorator pattern here, instead of subclassing CodeChecker with the desired functionality. It means that if we introduce some other functionality at a later point, we just re-wrap the CodeChecker instead of needing 6 (!!!) subclasses. It quickly spirals out of control after that...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/me wraps Xenopathic into a decorator....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*done
ee7dd54
to
6b35a60
Compare
if ($input->getOption('deprecated')) { | ||
$list = new DeprecationList(); | ||
} else { | ||
$list = new PrivateList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙈 This isn't actually the Decorator pattern... What happens if we introduce some more checking, that we might need to combine with DeprecationList and/or PrivateList? You have the same problem, needing many classes and subclasses to cover all possibilities.
Have a BasicList class, whose methods return empty arrays, then let DeprecationList and PrivateList take an ICheckList in the constructor, and forward the methods to that wrapped ICheckList. Then you create a list at the start ($list = new BasicList()
), then if we want to test for deprecation replace the object with the wrapped DeprecationList ($list = new DeprecationList($list)
), etc for all features.
Sorry to be such a pain, but I can see this needing a refactor in the (near?) future if it isn't done now. 🙊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, mixed it up a bit. Should be fixed now
Nice! Any reason why it's DeprecatedCheck or PrivateCheck? Can we not have PrivateCheck enabled by default (controllable by a new parameter would be cool) and enable DeprecatedCheck as well if the option is set? Or was the intention to do this? I can see |
I agree with @Xenopathic lets enable the extra checks by default. |
My idea was to be able to fail travis on private class usage and make travis "allow failure" for deprecated usage... so as long as it is possible to do those two separatly I'm fine with it |
@nickvergessen May I push to this branch? I'll implement the selectable features thing I mentioned above if you want 😄 |
@Xenopathic Do it. @nickvergessen is usually on vacation right now :P |
You can now specify the checkers you want enabled, with |
|
@MorrisJobke Ah, that's a side effect of the description concatenation. If both |
@Xenopathic Can we fix this? |
@MorrisJobke I have an idea... |
'checker', | ||
'c', | ||
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, | ||
'enable the specified checker', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is what people see as help, we should maybe add the available checkers here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The help text displays the default value, which is currently all the available checkers (all are enabled by default). If we include some non-default-on checkers later in the future, this could become an issue. The problem is, if we list all the checkers here, the default also gets displayed, so you will see the checkers twice (not to mention the help text line will be really long)
This is the help text:
--checker (-c) enable the specified checker (default: ["private","deprecation","strong-comparison"]) (multiple values allowed)
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, I didn't check the output. Seems okay when they output the default value.
Now the question is should we include all in the default (and I think we shouldn't, but private only)?
Well, that is why I wouldn't add them all by default... |
#17046 was merged, so I will add that when jenkins reported back |
By default, all are enabled, but specific ones can be selected through command line options.
d05ecba
to
3566dcf
Compare
A new inspection was created. |
Rebased to fix the oracle thing without timeout. |
Jenkins PR #17720 |
Tested and works nicely 👍 |
@Xenopathic want to review? ;) |
Code looks good, haven't tested it however. 👍 |
…ecated-classes Allow app check code for deprecated classes
Documentation/OP needs to be updated. It still has the old switch, which doesn't work and no explanation on the other valid options |
@oparoz posted in the docs repo: owncloud-archive/documentation#1736 |
Thanks. Added a link to the doc from the list of features for 8.2. |
Old behaviour (without parameter):
With deprecated parameter:
Requested at https://mailman.owncloud.org/pipermail/devel/2015-June/001301.html
I think it's quite useful.
Also fixing a bug (use statements could circumvent blacklisted classes)
@DeepDiver1975 @MorrisJobke @LukasReschke
Todo