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

deprecates integration with PHP Copy/Paste Detector (PHPCPD) library. #264

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -1485,13 +1485,13 @@ Do not ask any interactive question
`phpcpd`
--------

Run PHP Copy/Paste Detector on a plugin
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
2 changes: 1 addition & 1 deletion docs/GHAFileExplained.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:
if: ${{ !cancelled() }} # prevents CI run stopping if step failed.
run: moodle-plugin-ci phplint

- name: PHP Copy/Paste Detector
- name: PHP Copy/Paste Detector # DEPRECATED
continue-on-error: true # This step will show errors but will not fail
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpcpd
Expand Down
2 changes: 1 addition & 1 deletion docs/Help.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ inclide in the CI scenario. For detailed information, see [CLI commands and opti

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

**moodle-plugin-ci phpcpd**
**moodle-plugin-ci phpcpd (DEPRECATED)**

This step runs the PHP Copy/Paste Detector on your plugin. This helps to find
code duplication.
Expand Down
1 change: 1 addition & 0 deletions docs/TravisFileExplained.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ script:
- moodle-plugin-ci phplint
# This step runs the PHP Copy/Paste Detector on your plugin.
# This helps to find code duplication.
# (DEPRECATED)
- moodle-plugin-ci phpcpd
# This step runs the PHP Mess Detector on your plugin. This helps to find
# potential problems with your code which can result in
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This project supports the following testing frameworks and code analysis tools:
* [Mustache Linting](https://docs.moodle.org/dev/Templates)
* [Grunt tasks](https://docs.moodle.org/dev/Grunt)
* [PHP Linting](https://github.com/JakubOnderka/PHP-Parallel-Lint)
* [PHP Copy/Paste Detector](https://github.com/sebastianbergmann/phpcpd)
* [PHP Copy/Paste Detector (DEPRECATED)](https://github.com/sebastianbergmann/phpcpd)
* [PHP Mess Detector](http://phpmd.org)

## Requirements
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: 17 additions & 1 deletion src/Command/CopyPasteDetectorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

/**
* Run PHP Copy/Paste Detector on a plugin.
*
* @deprecated Since 4.4.0, to be removed in 5.0.0. No replacement is planned.
*/
class CopyPasteDetectorCommand extends AbstractPluginCommand
{
Expand All @@ -31,11 +33,25 @@
parent::configure();

$this->setName('phpcpd')
->setDescription('Run PHP Copy/Paste Detector on a plugin');
->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'

Check warning on line 47 in src/Command/CopyPasteDetectorCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Command/CopyPasteDetectorCommand.php#L42-L47

Added lines #L42 - L47 were not covered by tests
);
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;

Check warning on line 51 in src/Command/CopyPasteDetectorCommand.php

View check run for this annotation

Codecov / codecov/patch

src/Command/CopyPasteDetectorCommand.php#L49-L51

Added lines #L49 - L51 were not covered by tests
}
}

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

Expand Down
Loading