aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts/linters/cargo_workspace_dependencies.rb
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-07-21 08:08:15 +0900
committernsfisis <nsfisis@gmail.com>2026-07-21 08:08:45 +0900
commitc899a4675ca90507a420d901ef7fa26d8b285f23 (patch)
tree405b8049c3ac59c65d56792c96f4a8c316bf605b /scripts/linters/cargo_workspace_dependencies.rb
parent6b16a2cd672edcbfeaf7988591db92ed4c594ddc (diff)
downloadphp-shirabe-c899a4675ca90507a420d901ef7fa26d8b285f23.tar.gz
php-shirabe-c899a4675ca90507a420d901ef7fa26d8b285f23.tar.zst
php-shirabe-c899a4675ca90507a420d901ef7fa26d8b285f23.zip
refactor(lint): rewrite structural linters from Ruby to PHP
Fold scripts/lint and scripts/linters/*.rb into a standalone Composer project under scripts/linters/, matching the scripts/plugin-class-classifier/ convention. Uses no external packages, only PHP + Composer autoloading. Verified byte-for-byte identical output against the original Ruby implementation, both on the current repo (all linters pass) and on a synthetic fixture exercising every violation type. Entry point moves from `scripts/lint` to `scripts/linters/lint`.
Diffstat (limited to 'scripts/linters/cargo_workspace_dependencies.rb')
-rw-r--r--scripts/linters/cargo_workspace_dependencies.rb50
1 files changed, 0 insertions, 50 deletions
diff --git a/scripts/linters/cargo_workspace_dependencies.rb b/scripts/linters/cargo_workspace_dependencies.rb
deleted file mode 100644
index 6e4278fb..00000000
--- a/scripts/linters/cargo_workspace_dependencies.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-def cargo_workspace_dependencies(root_dir, excludes = [])
- pattern = root_dir.join('crates', '*', 'Cargo.toml').to_s
- errors = Dir.glob(pattern).sort.flat_map do |path|
- relative = Pathname.new(path).relative_path_from(root_dir).to_s
- next [] if excludes.include?(relative)
-
- find_non_workspace_deps(path, relative)
- end
-
- return true if errors.empty?
-
- puts 'Found `[dependencies]` / `[dev-dependencies]` entries that do not use `workspace = true`.'
- puts 'In a crate `Cargo.toml`, only `name.workspace = true` or `name = { workspace = true, ... }` is allowed:'
- errors.each do |err|
- puts " #{err}"
- end
- false
-end
-
-def find_non_workspace_deps(path, relative)
- errors = []
- current_section = nil
-
- File.read(path).each_line.with_index do |raw_line, idx|
- stripped = raw_line.chomp.strip
-
- if stripped =~ /\A\[([^\]]+)\]\z/
- current_section = $1
- next
- end
-
- next unless %w[dependencies dev-dependencies build-dependencies].include?(current_section)
- next if stripped.empty? || stripped.start_with?('#')
-
- if stripped =~ /\A([A-Za-z0-9_-]+)\.workspace\s*=\s*true\b/
- next
- elsif stripped =~ /\A([A-Za-z0-9_-]+)\s*=\s*\{(.+)\}\s*\z/
- name = $1
- inner = $2
- next if inner =~ /\bworkspace\s*=\s*true\b/
-
- errors << "#{relative}:#{idx + 1}: `#{name}` does not use `workspace = true`"
- elsif stripped =~ /\A([A-Za-z0-9_-]+)\s*=/
- name = $1
- errors << "#{relative}:#{idx + 1}: `#{name}` does not use `workspace = true`"
- end
- end
-
- errors
-end