Skip to content
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

Continuous integration tests fails on this plugin #5

Open
dcadiou opened this issue Nov 25, 2022 · 2 comments
Open

Continuous integration tests fails on this plugin #5

dcadiou opened this issue Nov 25, 2022 · 2 comments
Assignees

Comments

@dcadiou
Copy link
Contributor

dcadiou commented Nov 25, 2022

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 dcadiou self-assigned this Nov 25, 2022
dcadiou added a commit that referenced this issue Nov 25, 2022
@dcadiou
Copy link
Contributor Author

dcadiou commented Nov 25, 2022

With modifications made on branch issue_5_warning, CI tests passed.

@dcadiou
Copy link
Contributor Author

dcadiou commented Nov 25, 2022

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant