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

Feature/1088-code-style-setup #97

Merged
merged 15 commits into from
Jan 6, 2025
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
41 changes: 41 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Lint

on:
pull_request:
branches:
- stage
types:
- opened
- synchronize
- reopened

jobs:
php-cs-fixer:
runs-on: ubuntu-latest

strategy:
fail-fast: true

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.3"
tools: composer

- name: Install php-cs-fixer
run: composer require --dev friendsofphp/php-cs-fixer

- name: Run php-cs-fixer
run: vendor/bin/php-cs-fixer fix

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: fix code style"
commit_options: "--no-verify"
commit_user_name: "GitHub Actions"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/build
/dev-environment
js/nextcloud-swarm-plugin*.*
/.php_cs.cache
/.php-cs-fixer.cache

# Package Manages
/node_modules
Expand Down
21 changes: 20 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,31 @@

require_once './vendor/autoload.php';

use Nextcloud\CodingStandard\Config;
use Nextcloud\CodingStandard\Config as Base;
use PhpCsFixer\Runner\Parallel\ParallelConfig;

class Config extends Base {
public function getRules(array $rules = []): array
{
return [
...parent::getRules(), // Nextcloud Standard Rules
'@PSR12' => true,
'@PhpCsFixer' => true,
'global_namespace_import' => [
'import_classes' => true,
],
'trailing_comma_in_multiline' => ['elements' => ['arguments', 'arrays', 'match', 'parameters']],
];
}
}

$config = new Config();
$config
->setParallelConfig(new ParallelConfig(8))
->setRiskyAllowed(true)
->getFinder()
->ignoreVCSIgnored(true)
->notPath('dev-environment')
->notPath('build')
->notPath('l10n')
->notPath('src')
Expand Down
3 changes: 0 additions & 3 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

/**
* @copyright Copyright (c) 2022, MetaProvide Holding EKF
*
* @author Ron Trevor <ecoron@proton.me>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -21,7 +19,6 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
return ['routes' => [
[
Expand Down
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"autoload-dev": {
"psr-4": {
"OC\\": "dev-environment/nextcloud_source/lib/",
"OCP\\": "dev-environment/nextcloud_source/lib/public/",
"OCA\\Files_External\\": "dev-environment/nextcloud_source/apps/files_external/lib/",
"OCA\\Files_External_Ethswarm\\": "lib/"
Expand All @@ -10,8 +11,12 @@
"ext-curl": "*"
},
"require-dev": {
"nextcloud/coding-standard": "^0.5.0",
"christophwurst/nextcloud": "^22",
"ext-fileinfo": "*"
"nextcloud/coding-standard": "^1.3.2",
"ext-fileinfo": "*",
"friendsofphp/php-cs-fixer": "*"
},
"scripts": {
"cs:check": "./vendor/php-cs-fixer/shim/php-cs-fixer.phar fix --dry-run --diff",
"cs:fix": "./vendor/php-cs-fixer/shim/php-cs-fixer.phar fix"
}
}
Loading
Loading