Commit graph

38 commits

Author SHA1 Message Date
Erik Bernhardson
08dba3de30 Remove PhanUndeclaredStaticMethod from blacklist
There was a single instance of this issue which was reasonably simple
to solve. The code that triggered the issue was not wrong, but calling
the grandparent constructor directly is not the cleanest code so it
seems right to fix it. Switch revision initialization into an
overridable function to remove the need to even have a constructor in
the class.

Change-Id: Ic2af0d93e8d55e93061e3f4b5c7a4122509543f0
2018-08-28 05:38:43 +00:00
Timo Tijhof
55875bcd2d maintenance: Move backup.inc to a regular php class file
Move the class to maintenance/includes/, following the precedent
set by d788692076.

Bug: T184782
Change-Id: I0ba86e4401e2c97db4cf2ad9f0e78c04b5565ee8
2018-08-02 17:20:30 +01:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Erik Bernhardson
cba9297518 Remove PhanParamReqAfterOpt from blacklist
Change-Id: I569656068c9034f7325312afcce837e2712b4f29
2018-06-09 09:21:12 +00:00
Umherirrender
0123e91fc2 Remove renamed .inc files from phan config
Follow-Up: Ic441087702376b1ca0e70554c71cdf7ecad908af (for userOptions.inc)
Follow-Up: I999f5842625c752f01c1eb4b012431c4a24ce7ce (for importImages.inc)
Change-Id: I3e1c694f61960e9e4b50a7855927d039e93928fb
2018-05-31 18:44:51 +02:00
Kunal Mehta
9004601318 Enable a bunch of disabled phan checks that are no longer failing
Change-Id: I471bffa8a4aa20d22e7e1830a2b01fce3e099d9e
2018-05-17 23:27:59 -07:00
Kunal Mehta
c381dd0a99 Enable "PhanTypeInvalidRightOperand" phan checks
HTMLFormField subclasses triggered false positives when phan incorrectly
thought that $this->mOptions was only a boolean.

ReplacementArray $this->data was defined as possibly being boolean, but
in reality that never happened.

Change-Id: I06bae9c9952366ff7927df37373b146d570f4a02
2018-05-17 23:27:42 -07:00
Kunal Mehta
633e8dfb1b Enable "PhanUndeclaredVariable" phan check
All of the instances of it have been fixed. This would have prevented
T194899 from happening in the first place.

Change-Id: I19357ffc858022d3b89a040eafe9047f83df1c88
2018-05-17 22:43:12 -07:00
Umherirrender
35195668ee Remove empty skins folder from phan config
Similar to extensions folder there is nothing to do

Change-Id: I5bd9a8f70fb020325c892f04e3eac7a3e46d772a
2018-05-06 09:13:06 +02:00
Reedy
45a0f99734 Allow PHPUnit 6 optionally in require-dev
MediaWiki uses a back-compat layer to preserve most of the PHPUnit 4
runtime, so existing tests will continue to run fine with minimal
modification. Once PHP < 7.0 support is dropped, we can drop PHPUnit 4
support, and adapt tests to use PHPUnit 6 features directly.

Bug: T177132
Depends-On: I884b240307e3fcad253aa64eeae9944ed4eb7d50
Change-Id: I497712c7693d137be197a69873baa58383ce9646
2018-04-12 20:46:56 -07:00
Max Semenik
55497cdc1a Phan: resolve and reenable PhanAccessMethodProtected
Change-Id: I2bd7c787012f4f54600f3289d9d0d725f87788bc
2018-01-23 09:31:13 -08:00
Chad Horohoe
93d44c9a42 Move BaseDump into includes/export/
There's no reason for this to have to live in Maintenance land. It's
generally useful and lets us avoid some random require/include calls

Change-Id: I60419c7f9fc52313905053bbeb3aa81666c9160c
2018-01-08 22:10:25 -08:00
Max Semenik
99eb73c32e Update for Phan 0.10.1
Change-Id: Id292944b80eb0c81956b203ce95bb0def3b4b0a3
2017-11-07 22:52:38 +00:00
Umherirrender
bd741b83bc build: Updating mediawiki/mediawiki-codesniffer to 13.0.0
Change-Id: Ia24dbf015f2b4781683ca980a460d0ac3e85674e
2017-09-25 17:31:56 +02:00
addshore
a756f82851 Update phan issues & estimated counts
Since the last update there is a total of 550 less issues.
744 removed and 194 added in various places.
(roughly)

Change-Id: I0431773973c146e1492de72d869f6d33de4084e8
2017-06-30 14:10:04 +01:00
Antoine Musso
7671b2b71e Drop in replacement of eval.php based on psysh
eval.php is meant to eval() commands in MediaWiki global scope. We had
at least a couple attempts to move it to a regular Maintenance script.

As noted on the revert commit b475e930 r54839, using a Maintenance
script drop us in the callee function scope instead of the global scope
which is a hard requirement.

http://psysh.org/ is a Read-Eval-Print-Loop with color highlight, modern
code and more.

Add maintenance/shell.php script as MediaWikiShell class.

Passing command from stdin is supported.
Execution is forked for graceful handling of PHP fatal errors.
Colors!!
Support the undocumented '-d' arguments from eval.php:
  0 set $wgDebugLogFile to stdout. Eval.php used /dev/stdout, make it
    php://stdout in the new script.
  1 additionally set DBO_DEBUG on all the database load balancer servers

PHP globals have to be whitelisted which is not supported out of the box
by Psy. Upon request, the author of PsySh, Justin Hileman, kindly
provided a pass to inject globals (with the exceptions of super
globals). He agreed for code reuse:
    https://github.com/bobthecow/psysh/issues/353
The code was added to maintenance/CodeCleanerGlobalsPass.inc

Note that this is not a perfect simulation of global scope (but pretty
close): variables declared in the shell which did not exist before
won't be global unless the 'global' keword is used.

Example usage:

$ php maintenance/shell.php

>>> $wgFullyInitialised
=> true

>>> $hashar = User::newFromName( 'hashar' )
=> User {#274
     +mId: null,
     +mName: "Hashar",
     ...

>>> ls --long --all $h
<descriptive output of all object properties/methods>

Bug: T117661
Signed-off-by: Justin Hileman <justin@justinhileman.info>
Signed-off-by: Gergő Tisza <tgr.huwiki@gmail.com>
Change-Id: I3d6d42e138d3cc4a0aaafdd7f5f97cb17d8b8cb3
2017-02-13 08:34:38 +00:00
addshore
d8d408503c PHAN: Add tideways stub
Used in Xhprof

Change-Id: I9f208bbaa0799d194dbef61cad851995020a5d17
2017-01-30 16:25:59 +00:00
addshore
9252dff64b PHAN: load stubs from phpstorm-stubs library
Also add a single small stub for the Memcached class
constructor that is slightly wrong in the phpstorm
stubs library.

jetbrains/phpstorm-stubs has been added to packagist via:
https://github.com/JetBrains/phpstorm-stubs/pull/149

Change-Id: I1bca7390d1dc24c38d65c1c8968f356326ff4636
2017-01-30 16:25:47 +00:00
jenkins-bot
96491f80d3 Merge "PHAN: conditionally load stubs" 2017-01-23 18:11:43 +00:00
addshore
d9c717c089 PHAN: conditionally load stubs
Change-Id: I6f78c573468a393d82927d614df5bceda86a9e9c
2017-01-23 17:40:09 +01:00
Erik Bernhardson
e5b8bf4942 Un-blacklist PhanUndeclaredVariable
Undeclared variables are a very common error type that we want to catch
as often as possible. To avoid needing to refactor a variety of global
level code (mostly in old-style maintenance scripts) this ignores
undeclared variables in global scope. This is still a good improvement
over what was happening previously.

Change-Id: I50b41d571724244552074b9408abbdf6160aca59
2017-01-18 13:07:39 -08:00
WMDE-Fisch
7e32cbb6c3 Fixed typo in comment
Change-Id: I58dba2018a20c34537222ba7711a39c75855be52
2017-01-04 14:49:26 +00:00
Leszek Manicki
cb4bb23df6 Remove unused static methods in LanguageConverter subclasses
It seems LanguageConverter::parseManualRule was removed by
69dbeb97f1 (2008),
and LanguageConverter::parserConvert by
c568220e61 (2010),
so it seems safe and reasonable to remove their implementations
from few remaining language-specific Converter classes.

Change-Id: I7092f5c8856723fabd2b1f99944451344feb5711
2017-01-03 15:13:51 +01:00
jenkins-bot
c496cb3ff9 Merge "Remove unused Phan exception" 2016-12-19 21:31:03 +00:00
Max Semenik
0b2e6272b8 Remove unused Phan exception
Change-Id: Ib578336abfed02c8dce9ccb47ab22220ddcee856
2016-12-18 04:48:10 -08:00
Max Semenik
633e638cae Fix type annotation
Change-Id: I8996a7617c4723c9c4ff8f91d0f3767c9e67dd28
2016-12-16 17:11:51 -08:00
Max Semenik
d4f3e554d7 Decrease the number of 'function says it should return something' errors
Change-Id: Ib5115fe5bbaa67d8a6e54cc3ba1ba7020e239e11
2016-12-15 16:05:52 -08:00
Max Semenik
f23a964170 Fix type annotations
Change-Id: Ib72c98358b2f0b3b73b6f105adea47346373d46d
2016-12-15 14:11:12 -08:00
Erik Bernhardson
41f9c933b3 Fix two instances of calling function with too few args
At one point SearchIndexFieldDefinition was updated to require the
engine to be passed in, but it seems that update was missed here.

BackupDumper::loadPlugin() requires the second argument, set it to
the empty string to keep current behaviour.

Change-Id: Ifbd8fc4870ff63b2d338f8bb4d251d7a3477b989
2016-12-15 13:24:40 -08:00
Erik Bernhardson
2e8923079b Correct DatabaseSqlite::unionQueries annotation
The annotation was claiming string, but it's very obvious from
the usage the it should be string[].

Change-Id: I99849a338971590ca68dfb175b2458ad5ebc0df2
2016-12-15 11:22:03 -08:00
jenkins-bot
457d5b702c Merge "Fix parameter type docs" 2016-12-14 19:41:20 +00:00
jenkins-bot
ffd5f40293 Merge "Document type of LogEntry::isPatrollable property" 2016-12-14 19:30:11 +00:00
Leszek Manicki
95b9d82a3a Fix parameter type docs
Changes:
 - uses int instead of number as param and return value type,
 - uses stdClass instead of stdObject
 - fixes ResourceLoaderClientHtml constructor's $target param type:
   it is string|null, not an array (previously misspelled as "aray")
 - changes the type of references to XML parser in XMP lib to resource
   instead of not existing XMLParser

Change-Id: I98c363ebc6658d1f4dcabad97a9a92f3fcd7ea8c
2016-12-14 17:01:47 +01:00
Leszek Manicki
584fd0c75b Document type of LogEntry::isPatrollable property
Change-Id: I557b92f25f15f57123af329c79ef1752025aedf3
2016-12-14 16:09:34 +01:00
Leszek Manicki
29737562b2 Fix assigning void return value to a variable
Change-Id: I1e675d121938c5b6b7f8165681c645154e3a70d0
2016-12-14 11:07:42 +01:00
Erik Bernhardson
3becc477a9 Add script to support per-line @suppress annotations in Phan
Adds the functionality of per-line @suppress annotations. Phan already
supports per-class or per-method annotations, but does not have any
per-line support due to the PHP AST only returning comments that are
class/property/method level docblocks.

This is a bit of a hack, but get's the job done. Removes the
PhanTypeInvalidLeftOperand issue from blacklist and suppresses it
to demonstrate the supression works as expected.

Change-Id: I5066b3b431fb69175a711ee366e95f31c7c47639
2016-12-13 11:54:10 -08:00
Erik Bernhardson
5c6c93c76d Adjust phan to allow for making progress strengthening analysis
With phan set to only report critical errors it will be quite hard
to cleanup the code base to the point where we are running stronger
analysis. Instead of setting minimimum severity to critical, set
minimum severity to low and suppress all existing issues.

This will allow developers to choose an issue type from the list, fix
it, and update the config.php to report on the issue in the future.

Change-Id: I2771a4ff37f43cca215b939ed7d82f137d72cea6
2016-12-13 11:21:17 -08:00
Erik Bernhardson
f5b4bd19b2 Add configuration for running etsy/phan against core
Adds the necessary configuration and stubs for phan static analysis to
run against mediawiki core. A variety of fixes have been applied to core
recently such with this current configuration we are completely passing,
except for one issue with a bug in Phan (https://github.com/etsy/phan/issues/286)

In it's current configuration Phan will detect fatal errors trying to
access non existant classes, undefined method calls, and other errors.
The analysis can be expanded as we cleanup more of the codebase.  This
is in preparation for working on getting the CI to run phan as part of
the review process. I have found phan to be usefull in CirrusSearch
(although with stricter config) for catching bugs and I think it could
help in core as well.

We arn't too far from being able to disable `null_casts_as_any_type`,
there are only a few classes that need adjusting. Lots more work needs
to be done to reduce `minimum_severity` from 10 to 5 (normal) or
0 (low).

Change-Id: Iafd55b1380f37d7b0d195eed081f8042166690e8
2016-12-07 20:04:01 -08:00