aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohsin Kaleem <mohkale@kisara.moe>2023-04-22 11:53:13 +0100
committerGitHub <noreply@github.com>2023-04-22 11:53:13 +0100
commit95bea3371b65ff562f91a74d52cf31cd3b883f8c (patch)
treeb2675e84c703fd26c7262a5c10d0525094d9c27f
parent93c11bf5e35246f0fa593850c292ecb96c6c4d00 (diff)
Add rubocop formatter (#176)
-rw-r--r--CHANGELOG.md2
-rw-r--r--apheleia.el2
-rw-r--r--test/formatters/installers/rubocop.bash3
l---------test/formatters/samplecode/rubocop/in.rb1
-rw-r--r--test/formatters/samplecode/rubocop/out.rb15
5 files changed, 23 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9f7dd41..59bff6a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,6 +31,7 @@ The format is based on [Keep a Changelog].
* [`html-tidy`](https://www.html-tidy.org/) for HTML/XML ([#173]).
* [`perltidy`](https://perltidy.sourceforge.net/) for
[perl](https://www.perl.org/) ([#175]).
+* [`rubocop`](https://github.com/rubocop/rubocop) for [ruby](https://www.ruby-lang.org/en/) ([#176]).
[#168]: https://github.com/radian-software/apheleia/pull/168
[#169]: https://github.com/radian-software/apheleia/pull/169
@@ -40,6 +41,7 @@ The format is based on [Keep a Changelog].
[#173]: https://github.com/radian-software/apheleia/pull/173
[#174]: https://github.com/radian-software/apheleia/pull/174
[#175]: https://github.com/radian-software/apheleia/pull/175
+[#176]: https://github.com/radian-software/apheleia/pull/176
[#182]: https://github.com/radian-software/apheleia/pull/182
[#187]: https://github.com/radian-software/apheleia/pull/187
diff --git a/apheleia.el b/apheleia.el
index 3251232..0c6d37e 100644
--- a/apheleia.el
+++ b/apheleia.el
@@ -127,6 +127,8 @@
. (npx "prettier" "--stdin-filepath" filepath "--parser=yaml"
(apheleia-formatters-js-indent "--use-tabs" "--tab-width")))
(purs-tidy . (npx "purs-tidy" "format"))
+ (rubocop . ("rubocop" "--stdin" filepath "--auto-correct"
+ "--stderr" "--format" "quiet" "--fail-level" "fatal"))
(shfmt . ("shfmt"
"-filename" filepath
"-ln" (cl-case (bound-and-true-p sh-shell)
diff --git a/test/formatters/installers/rubocop.bash b/test/formatters/installers/rubocop.bash
new file mode 100644
index 0000000..db8c835
--- /dev/null
+++ b/test/formatters/installers/rubocop.bash
@@ -0,0 +1,3 @@
+apt-get install -y ruby ruby-dev gcc
+
+gem install rubocop
diff --git a/test/formatters/samplecode/rubocop/in.rb b/test/formatters/samplecode/rubocop/in.rb
new file mode 120000
index 0000000..2881c83
--- /dev/null
+++ b/test/formatters/samplecode/rubocop/in.rb
@@ -0,0 +1 @@
+../prettier-ruby/in.rb \ No newline at end of file
diff --git a/test/formatters/samplecode/rubocop/out.rb b/test/formatters/samplecode/rubocop/out.rb
new file mode 100644
index 0000000..a677a10
--- /dev/null
+++ b/test/formatters/samplecode/rubocop/out.rb
@@ -0,0 +1,15 @@
+d = [30_644_250_780, 9_003_106_878,
+ 30_636_278_846, 66_641_217_692, 4_501_790_980,
+ 67_124_603_036, 13_161_973_916, 66_606_629_920,
+ 30_642_677_916, 30_643_069_058]; a = []
+s = $*[0]
+s.each_byte do |b|
+ a << ('%036b' % d[b
+ .chr.to_i]).scan(/\d{6}/)
+end
+a.transpose.each do |a|
+ a.join.each_byte do |i|
+ print i == 49 ? ($*[1] || '#') : 32.chr
+ end
+ puts
+end