Skip to content

Commit 8124fe7

Browse files
authored
Merge pull request #264 from stopfstedt/deprecate_copy_paste_detector
deprecates integration with PHP Copy/Paste Detector (PHPCPD) library.
2 parents 0aef673 + 02cb44e commit 8124fe7

File tree

8 files changed

+31
-6
lines changed

8 files changed

+31
-6
lines changed

docs/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
99
The format of this change log follows the advice given at [Keep a CHANGELOG](http://keepachangelog.com).
1010

1111
## [Unreleased]
12+
1213
### Changed
1314
- 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.
1415
* ACTION SUGGESTED: In order to avoid the node 16 deprecation warnings, update your workflows to use `actions/checkout@v4`.
1516

17+
### Deprecated
18+
- 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.
19+
- 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).
20+
1621
## [4.3.2] - 2024-01-26
1722
### Changed
1823
- Modified internal CI scripts towards better Codecov future support.

docs/CLI.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,13 +1485,13 @@ Do not ask any interactive question
14851485
`phpcpd`
14861486
--------
14871487

1488-
Run PHP Copy/Paste Detector on a plugin
1488+
Run PHP Copy/Paste Detector on a plugin (**DEPRECATED**)
14891489

14901490
### Usage
14911491

14921492
* `phpcpd <plugin>`
14931493

1494-
Run PHP Copy/Paste Detector on a plugin
1494+
Run PHP Copy/Paste Detector on a plugin (**DEPRECATED**)
14951495

14961496
### Arguments
14971497

docs/GHAFileExplained.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ jobs:
142142
if: ${{ !cancelled() }} # prevents CI run stopping if step failed.
143143
run: moodle-plugin-ci phplint
144144

145-
- name: PHP Copy/Paste Detector
145+
- name: PHP Copy/Paste Detector # DEPRECATED
146146
continue-on-error: true # This step will show errors but will not fail
147147
if: ${{ !cancelled() }}
148148
run: moodle-plugin-ci phpcpd

docs/Help.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ inclide in the CI scenario. For detailed information, see [CLI commands and opti
2727

2828
This step lints your PHP files to check for syntax errors.
2929

30-
**moodle-plugin-ci phpcpd**
30+
**moodle-plugin-ci phpcpd (DEPRECATED)**
3131

3232
This step runs the PHP Copy/Paste Detector on your plugin. This helps to find
3333
code duplication.

docs/TravisFileExplained.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ script:
131131
- moodle-plugin-ci phplint
132132
# This step runs the PHP Copy/Paste Detector on your plugin.
133133
# This helps to find code duplication.
134+
# (DEPRECATED)
134135
- moodle-plugin-ci phpcpd
135136
# This step runs the PHP Mess Detector on your plugin. This helps to find
136137
# potential problems with your code which can result in

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ This project supports the following testing frameworks and code analysis tools:
2828
* [Mustache Linting](https://docs.moodle.org/dev/Templates)
2929
* [Grunt tasks](https://docs.moodle.org/dev/Grunt)
3030
* [PHP Linting](https://github.com/JakubOnderka/PHP-Parallel-Lint)
31-
* [PHP Copy/Paste Detector](https://github.com/sebastianbergmann/phpcpd)
31+
* [PHP Copy/Paste Detector (DEPRECATED)](https://github.com/sebastianbergmann/phpcpd)
3232
* [PHP Mess Detector](http://phpmd.org)
3333

3434
## Requirements

phpunit.xml.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@
1111
<directory suffix=".php">./src/</directory>
1212
</include>
1313
</coverage>
14+
<php>
15+
<const name="PHPUNIT_TEST" value="true"/>
16+
</php>
1417
</phpunit>

src/Command/CopyPasteDetectorCommand.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
/**
2525
* Run PHP Copy/Paste Detector on a plugin.
26+
*
27+
* @deprecated Since 4.4.0, to be removed in 5.0.0. No replacement is planned.
2628
*/
2729
class CopyPasteDetectorCommand extends AbstractPluginCommand
2830
{
@@ -31,11 +33,25 @@ protected function configure(): void
3133
parent::configure();
3234

3335
$this->setName('phpcpd')
34-
->setDescription('Run PHP Copy/Paste Detector on a plugin');
36+
->setDescription('Run PHP Copy/Paste Detector on a plugin (**DEPRECATED**)');
3537
}
3638

3739
protected function execute(InputInterface $input, OutputInterface $output): int
3840
{
41+
if (!defined('PHPUNIT_TEST')) { // Only show deprecation warnings in non-test environments.
42+
trigger_deprecation(
43+
'moodle-plugin-ci',
44+
'4,4,0',
45+
'The "%s" command is deprecated and will be removed in %s. No replacement is planned.',
46+
$this->getName(),
47+
'5.0.0'
48+
);
49+
if (getenv('GITHUB_ACTIONS')) { // Only show deprecation annotations in GitHub Actions.
50+
echo '::warning title=Deprecated command::The phpcpd command ' .
51+
'is deprecated and will be removed in 5.0.0. No replacement is planned.' . PHP_EOL;
52+
}
53+
}
54+
3955
$timer = new Timer();
4056
$timer->start();
4157

0 commit comments

Comments
 (0)