grp-attestoodle / moodle-block_attestoodle

views of training at course level
GNU General Public License v3.0
1 stars 0 forks source link

Continuous integration tests fails on this plugin #5

Open dcadiou opened 2 years ago

dcadiou commented 2 years ago

Recent commits pushed has fail CI tests. Failures are not linked with recent changes, but seems to be rather old.

See, for instance, https://github.com/grp-attestoodle/moodle-block_attestoodle/actions/runs/3541794958/jobs/5946505639

Failures detected :

0s
Run moodle-plugin-ci codechecker --max-warnings 0
 RUN  Moodle CodeSniffer standard on block_attestoodle
.EW..E..W 9 / 9 (100%)

FILE: /home/runner/work/moodle-block_attestoodle/moodle-block_attestoodle/moodle/blocks/attestoodle/block_attestoodle.php
-------------------------------------------------------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
-------------------------------------------------------------------------------------------------------------------------
  66 | ERROR | global $PAGE cannot be used in block classes. Use $this->page.
     |       | (moodle.PHP.ForbiddenGlobalUse.BadGlobal)
 192 | ERROR | global $PAGE cannot be used in block classes. Use $this->page.
     |       | (moodle.PHP.ForbiddenGlobalUse.BadGlobal)
-------------------------------------------------------------------------------------------------------------------------

FILE: /home/runner/work/moodle-block_attestoodle/moodle-block_attestoodle/moodle/blocks/attestoodle/classes/privacy/provider.php
------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------
 27 | WARNING | Unexpected MOODLE_INTERNAL check. No side effects or multiple artifacts detected.
    |         | (moodle.Files.MoodleInternal.MoodleInternalNotNeeded)
------------------------------------------------------------------------------------------------------------------------------------

FILE: /home/runner/work/moodle-block_attestoodle/moodle-block_attestoodle/moodle/blocks/attestoodle/edit_form.php
------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AND 1 WARNING AFFECTING 2 LINES
------------------------------------------------------------------------------------------------------------------------------------
 24 | WARNING | [ ] Unexpected MOODLE_INTERNAL check. No side effects or multiple artifacts detected.
    |         |     (moodle.Files.MoodleInternal.MoodleInternalNotNeeded)
 59 | ERROR   | [x] File must end with a newline character (Generic.Files.EndFileNewline.NotFound)
------------------------------------------------------------------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
------------------------------------------------------------------------------------------------------------------------------------

FILE: /home/runner/work/moodle-block_attestoodle/moodle-block_attestoodle/moodle/blocks/attestoodle/lib.php
------------------------------------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------
 25 | WARNING | Unexpected MOODLE_INTERNAL check. No side effects or multiple artifacts detected.
    |         | (moodle.Files.MoodleInternal.MoodleInternalNotNeeded)
------------------------------------------------------------------------------------------------------------------------------------

Time: 331ms; Memory: 14MB

Error: Process completed with exit code 1.
1s
Run moodle-plugin-ci phpdoc
 RUN  Moodle PHPDoc Checker on block_attestoodle
/home/runner/work/moodle-block_attestoodle/moodle-block_attestoodle/moodle/blocks/attestoodle/db/access.php
/home/runner/work/moodle-block_attestoodle/moodle-block_attestoodle/moodle/blocks/attestoodle/block_attestoodle.php
/home/runner/work/moodle-block_attestoodle/moodle-block_attestoodle/moodle/blocks/attestoodle/classes/privacy/provider.php
    Line 32: Package tool_save_attestoodle is not valid
/home/runner/work/moodle-block_attestoodle/moodle-block_attestoodle/moodle/blocks/attestoodle/version.php
/home/runner/work/moodle-block_attestoodle/moodle-block_attestoodle/moodle/blocks/attestoodle/certif.php
/home/runner/work/moodle-block_attestoodle/moodle-block_attestoodle/moodle/blocks/attestoodle/edit_form.php
/home/runner/work/moodle-block_attestoodle/moodle-block_attestoodle/moodle/blocks/attestoodle/lang/fr/block_attestoodle.php
/home/runner/work/moodle-block_attestoodle/moodle-block_attestoodle/moodle/blocks/attestoodle/lang/en/block_attestoodle.php
/home/runner/work/moodle-block_attestoodle/moodle-block_attestoodle/moodle/blocks/attestoodle/lib.php
dcadiou commented 2 years ago

With modifications made on branch issue_5_warning, CI tests passed.

dcadiou commented 2 years ago

Warings/ Errors explanations

For error "global $PAGE cannot be used in block classes. Use $this->page."

I just replaced $PAGE with $this->Page as asked. I suppos that $PAGE is not accessible from within a block plugin.

For error "Package tool_save_attestoodle is not valid"

I replaced the wrong reference to another plugin (probable a plugin name copied from another plugin and forgotten here) by the current one (as in the previous block of code in the same file).

For the warning "Unexpected MOODLE_INTERNAL check"

I suppressed lines that performs this check, where it is indicated. As I understood, this check is supposed to prevent direct call of the php file from outside of the plugin. However, for all files that received this warning, the content is only defining functions or classes, and calling this from outside would not produce anything dangerous things, because a function alone does nothing if it isn't called. Idem for a class, defining a class won't do nothing if these class is not instanciated.

So these warning may indicates that in such situations (check + non dangerous code) performing this MOODLE_INTERNAL check is unuseful. Besides, other files in the plugin that also contains the check but contains instructions that performs something, such as affecting variable, did not received such warning (consequently I didn't suppressed anything in them).