Skip to content

Commit

Permalink
Add a few details towards phpcpd deprecation
Browse files Browse the repository at this point in the history
- Add details to changelog.
- Emit a Symfony deprecation (but if running unit tests).
- Add a GH Workflow annotation to warn devs.

Note that, as a result of the changes in this commit,
code coverage will slightly decrease, because some
of the changes are unreachable when running unit tests,
but that's by design and on purpose, should be acceptable.
  • Loading branch information
stronk7 committed Feb 4, 2024
1 parent 72b5f65 commit 292b52c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
5 changes: 5 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
The format of this change log follows the advice given at [Keep a CHANGELOG](http://keepachangelog.com).

## [Unreleased]

### Changed
- Updated all uses of `actions/checkout` from `v3` (using node 16) to `v4` (using node 20), because [actions using node 16 are deprecated](https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/) and will stop working in the future.
* ACTION SUGGESTED: In order to avoid the node 16 deprecation warnings, update your workflows to use `actions/checkout@v4`.

### Deprecated
- The `phpcpd` command (that uses the [PHP Copy/Paste Detector](https://github.com/sebastianbergmann/phpcpd), now abandoned) has been deprecated in this `moodle-plugin-ci` release (4.4.0) and will be removed in 5.0.0. No replacement is planned.
- ACTION SUGGESTED: In order to avoid deprecation warnings or annotations, proceed to remove this command from your workflows. Note that any use will throw an error in the next major release (5.0.0).

## [4.3.2] - 2024-01-26
### Changed
- Modified internal CI scripts towards better Codecov future support.
Expand Down
14 changes: 3 additions & 11 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ title: Moodle Plugin CI Commands
* [`mustache`](#mustache)
* [`parallel`](#parallel)
* [`phpcbf`](#phpcbf)
* [`phpcpd` (DEPRECATED)](#phpcpd)
* [`phpcpd`](#phpcpd)
* [`phpcs`](#phpcs)
* [`phpdoc`](#phpdoc)
* [`phplint`](#phplint)
Expand Down Expand Up @@ -1485,21 +1485,13 @@ Do not ask any interactive question
`phpcpd`
--------

Run PHP Copy/Paste Detector on a plugin.

### Deprecation Notice

[PHP Copy/Paste Detector](https://github.com/sebastianbergmann/phpcpd) has been abandoned by its maintainers.

The integration with it will be removed without replacement from future versions of this plugin.

_Usage of the `phpcpd` command is discouraged._
Run PHP Copy/Paste Detector on a plugin (**DEPRECATED**)

### Usage

* `phpcpd <plugin>`

Run PHP Copy/Paste Detector on a plugin
Run PHP Copy/Paste Detector on a plugin (**DEPRECATED**)

### Arguments

Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@
<directory suffix=".php">./src/</directory>
</include>
</coverage>
<php>
<const name="PHPUNIT_TEST" value="true"/>
</php>
</phpunit>
18 changes: 16 additions & 2 deletions src/Command/CopyPasteDetectorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* Run PHP Copy/Paste Detector on a plugin.
*
* @deprecated
* @deprecated Since 4.4.0, to be removed in 5.0.0. No replacement is planned.
*/
class CopyPasteDetectorCommand extends AbstractPluginCommand
{
Expand All @@ -33,11 +33,25 @@ protected function configure(): void
parent::configure();

$this->setName('phpcpd')
->setDescription('Run PHP Copy/Paste Detector on a plugin (DEPRECATED)');
->setDescription('Run PHP Copy/Paste Detector on a plugin (**DEPRECATED**)');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
if (!defined('PHPUNIT_TEST')) { // Only show deprecation warnings in non-test environments.
trigger_deprecation(
'moodle-plugin-ci',
'4,4,0',
'The "%s" command is deprecated and will be removed in %s. No replacement is planned.',
$this->getName(),
'5.0.0'
);
if (getenv('GITHUB_ACTIONS')) { // Only show deprecation annotations in GitHub Actions.
echo '::warning title=Deprecated command::The phpcpd command ' .
'is deprecated and will be removed in 5.0.0. No replacement is planned.' . PHP_EOL;
}
}

$timer = new Timer();
$timer->start();

Expand Down

0 comments on commit 292b52c

Please sign in to comment.