Skip to content

Commit

Permalink
CONTRIB-5732 reporting: allow web to skip warnings (warningSeverity)
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Jan 31, 2016
1 parent e133a39 commit fb11e2b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

$path = optional_param('path', '', PARAM_PATH);
$exclude = optional_param('exclude', '', PARAM_NOTAGS);
$includewarnings = optional_param('includewarnings', true, PARAM_BOOL);

$pageparams = array();
if ($path) {
Expand All @@ -36,6 +37,7 @@
if ($exclude) {
$pageparams['exclude'] = $exclude;
}
$pageparams['includewarnings'] = $includewarnings;

admin_externalpage_setup('local_codechecker', '', $pageparams);

Expand Down Expand Up @@ -67,6 +69,7 @@
$cli = new local_codechecker_codesniffer_cli();
$cli->setReport('local_codechecker'); // Using own custom xml format for easier handling later.
$cli->setReportFile($reportfile); // Send the report to dataroot temp.
$cli->setIncludeWarnings($includewarnings); // Decide if we want to show warnings (defaults yes).
$phpcs->setCli($cli);
$phpcs->setIgnorePatterns(local_codesniffer_get_ignores($exclude));
$phpcs->process(local_codechecker_clean_path($fullpath),
Expand Down
1 change: 1 addition & 0 deletions lang/en/local_codechecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<p>Enter a path relative to the Moodle code root, for example: {$a->path}.</p>
<p>You can enter either a specific PHP file, or to a folder to check all the files it contains.</p>
<p>To exclude files, a comma separated list of substr matching paths can be used, for example: {$a->excludeexample}. Asterisks are allowed as wildchars at any place.</p>';
$string['includewarnings'] = 'Include warnings';
$string['invalidpath'] = 'Invalid path {$a}';
$string['moodlecodingguidelines'] = 'Moodle coding guidelines';
$string['numerrorswarnings'] = '{$a->errors} error(s) and {$a->warnings} warning(s)';
Expand Down
8 changes: 8 additions & 0 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ protected function definition() {
$mform->setType('exclude', PARAM_NOTAGS);
$mform->setDefault('exclude', '*/yui/build/*, */tests/fixtures/*');

$mform->addElement('advcheckbox', 'includewarnings', get_string('includewarnings', 'local_codechecker'));
$mform->setType('includewarnings', PARAM_BOOL);

$mform->addElement('submit', 'submitbutton', get_string('check', 'local_codechecker'));
}
}
Expand Down Expand Up @@ -84,6 +87,11 @@ public function setReportFile($reportfile) {
$this->reportfile = $reportfile;
}

/** Set the warnings flag to use */
public function setIncludeWarnings($includewarnings) {
$this->warningSeverity = (int)$includewarnings;
}

/* Overload method to inject our settings */
public function getCommandLineValues() {

Expand Down

0 comments on commit fb11e2b

Please sign in to comment.