From 50f1aaa16dbf1238a33ce9d1d844152a21048888 Mon Sep 17 00:00:00 2001 From: naman9271 Date: Sun, 16 Nov 2025 02:20:39 +0530 Subject: [PATCH] linitng setup added --- .editorconfig | 49 ++++++++++++++++++++++++++++++++++++++++ .gitignore | 4 ++++ .php-cs-fixer.php | 50 +++++++++++++++++++++++++++++++++++++++++ .phpcs.xml | 41 +++++++++++++++++++++++++++++++++ openml_OS/composer.json | 10 ++++++++- 5 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 .editorconfig create mode 100644 .php-cs-fixer.php create mode 100644 .phpcs.xml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..551f47d7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,49 @@ +# EditorConfig helps maintain consistent coding styles +# https://editorconfig.org + +root = true + +# All files +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +# PHP files +[*.php] +indent_style = space +indent_size = 4 + +# JavaScript files +[*.js] +indent_style = space +indent_size = 2 + +# CSS files +[*.css] +indent_style = space +indent_size = 2 + +# JSON files +[*.json] +indent_style = space +indent_size = 2 + +# YAML files +[*.{yml,yaml}] +indent_style = space +indent_size = 2 + +# Markdown files +[*.md] +trim_trailing_whitespace = false + +# Makefile +[Makefile] +indent_style = tab + +# SQL files +[*.sql] +indent_style = space +indent_size = 4 diff --git a/.gitignore b/.gitignore index 592e08b5..cdbdf063 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,7 @@ docs/site/ *.DS_store openml_OS/vendor/ openapi/vendor/ + +# PHP linting cache files +.php-cs-fixer.cache +.phpcs-cache diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 00000000..be037712 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,50 @@ +in([ + __DIR__ . '/openml_OS/controllers', + __DIR__ . '/openml_OS/models', + __DIR__ . '/openml_OS/helpers', + __DIR__ . '/openml_OS/libraries', + __DIR__ . '/openml_OS/core', + ]) + ->exclude([ + 'vendor', + 'third_party', + 'cache', + 'logs', + ]) + ->name('*.php') + ->notName('*.blade.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +return (new Config()) + ->setRules([ + '@PSR12' => true, + 'array_syntax' => ['syntax' => 'short'], + 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'no_unused_imports' => true, + 'not_operator_with_successor_space' => false, + 'trailing_comma_in_multiline' => ['elements' => ['arrays']], + 'phpdoc_scalar' => true, + 'unary_operator_spaces' => true, + 'binary_operator_spaces' => true, + 'blank_line_before_statement' => [ + 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], + ], + 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_var_without_name' => true, + 'single_trait_insert_per_statement' => true, + 'space_after_semicolon' => true, + 'no_whitespace_in_blank_line' => true, + 'concat_space' => ['spacing' => 'one'], + ]) + ->setFinder($finder) + ->setLineEnding("\n") + ->setIndent(" ") // 4 spaces + ->setUsingCache(true) + ->setCacheFile(__DIR__ . '/.php-cs-fixer.cache'); diff --git a/.phpcs.xml b/.phpcs.xml new file mode 100644 index 00000000..9f097f71 --- /dev/null +++ b/.phpcs.xml @@ -0,0 +1,41 @@ + + + PHP CodeSniffer configuration for OpenML + + + + + + + + + + openml_OS/controllers + openml_OS/models + openml_OS/helpers + openml_OS/libraries + openml_OS/core + + + */vendor/* + */third_party/* + */cache/* + */logs/* + */system/* + + + + 0 + + + + + 0 + + + + + + + + diff --git a/openml_OS/composer.json b/openml_OS/composer.json index 7c2d006b..94d9dbeb 100644 --- a/openml_OS/composer.json +++ b/openml_OS/composer.json @@ -18,6 +18,14 @@ "paragonie/random_compat": "Provides better randomness in PHP 5.x" }, "require-dev": { - "mikey179/vfsstream": "1.6.*" + "mikey179/vfsstream": "1.6.*", + "squizlabs/php_codesniffer": "^3.7", + "friendsofphp/php-cs-fixer": "^3.40" + }, + "scripts": { + "lint": "phpcs --standard=.phpcs.xml", + "lint:fix": "phpcbf --standard=.phpcs.xml", + "cs:check": "php-cs-fixer fix --dry-run --diff", + "cs:fix": "php-cs-fixer fix" } }