From d8874654e62aab5107b0de891706025c0af1e789 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" Date: Sun, 16 Jan 2022 18:50:28 +0100 Subject: [PATCH] Downgrade to warning the new MoodleInternalNotNeeded error When the new detection was planned at #152, it was agreed to make it a warning, not an error. Instead, I missed that completely and implemented it as error. So, this simple PR just downgrades the check to warning, as originally planned. --- classes/privacy/provider.php | 11 +---------- moodle/Sniffs/Files/MoodleInternalSniff.php | 2 +- moodle/tests/files_moodleinternal_test.php | 4 ++-- renderer.php | 12 +----------- 4 files changed, 5 insertions(+), 24 deletions(-) diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 4f2a85ed..0a4e6fe5 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -14,21 +14,12 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Privacy Subsystem implementation for local_codechecker. - * - * @package local_codechecker - * @copyright 2018 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace local_codechecker\privacy; -defined('MOODLE_INTERNAL') || die(); - /** * Privacy Subsystem for local_codechecker implementing null_provider. * + * @package local_codechecker * @copyright 2018 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ diff --git a/moodle/Sniffs/Files/MoodleInternalSniff.php b/moodle/Sniffs/Files/MoodleInternalSniff.php index 7a7eb8a8..e49b37d4 100644 --- a/moodle/Sniffs/Files/MoodleInternalSniff.php +++ b/moodle/Sniffs/Files/MoodleInternalSniff.php @@ -122,7 +122,7 @@ public function process(File $file, $pointer) { // Having MOODLE_INTERNAL, not having side effects and not having multiple artifacts, error. if ($hasMoodleInternal && !$hasSideEffects && !$hasMultipleArtifacts) { - $file->addError('Unexpected MOODLE_INTERNAL check. No side effects or multiple artifacts detected.', + $file->addWarning('Unexpected MOODLE_INTERNAL check. No side effects or multiple artifacts detected.', $pointer, 'MoodleInternalNotNeeded'); return; } diff --git a/moodle/tests/files_moodleinternal_test.php b/moodle/tests/files_moodleinternal_test.php index 76b93d8e..04bfe885 100644 --- a/moodle/tests/files_moodleinternal_test.php +++ b/moodle/tests/files_moodleinternal_test.php @@ -174,10 +174,10 @@ public function test_moodle_files_moodleinternal_unexpected() { $this->set_sniff('moodle.Files.MoodleInternal'); $this->set_fixture(__DIR__ . '/fixtures/files/moodleinternal/unexpected.php'); - $this->set_errors([ + $this->set_errors([]); + $this->set_warnings([ 17 => 'MoodleInternalNotNeeded' ]); - $this->set_warnings([]); $this->verify_cs_results(); } diff --git a/renderer.php b/renderer.php index 62100448..f7e4f1b7 100644 --- a/renderer.php +++ b/renderer.php @@ -14,20 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Code checker renderers. - * - * @package local_codechecker - * @copyright 2011 The Open University - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die; - - /** * Renderer for displaying code-checker reports as HTML. * + * @package local_codechecker * @copyright 2011 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */