File tree Expand file tree Collapse file tree 4 files changed +55
-10
lines changed Expand file tree Collapse file tree 4 files changed +55
-10
lines changed Original file line number Diff line number Diff line change 1+ name : Ruby Style Check
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ # paths:
7+ # - '**/*.rb'
8+
9+ jobs :
10+ style :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - uses : actions/checkout@v4
14+
15+ - name : Set up Ruby
16+ uses : ruby/setup-ruby@v1
17+ with :
18+ ruby-version : ' 3.4'
19+ bundler-cache : true
20+
21+ - name : Install RuboCop
22+ run : gem install rubocop
23+
24+ - name : Run RuboCop
25+ run : rubocop
Original file line number Diff line number Diff line change 1+ require :
2+ - rubocop-rake
3+ - rubocop-rspec
4+
5+ AllCops :
6+ NewCops : enable
7+ TargetRubyVersion : 3.4
8+
9+ Style/Documentation :
10+ Enabled : false
11+
12+ Layout/LineLength :
13+ Max : 120
14+
15+ Style/StringLiterals :
16+ EnforcedStyle : single_quotes
17+
18+ Style/FrozenStringLiteralComment :
19+ Enabled : true
20+ EnforcedStyle : always
Original file line number Diff line number Diff line change 11def functional_style ( input )
2- lefts , rights = input . split ( " \n " ) . map {
2+ lefts , rights = input . split ( '\n' ) . map {
33 |line | line . split ( ' ' ) . map ( &:to_i )
44 } . transpose
55
@@ -12,13 +12,13 @@ def functional_style(input)
1212end
1313
1414def imperative_style ( input )
15- lines = input . split ( " \n " )
15+ lines = input . split ( '\n' )
1616
1717 lefts = [ ]
1818 rights = [ ]
1919
2020 for line in lines
21- left , right = line . split ( " " )
21+ left , right = line . split ( ' ' )
2222 lefts << left . to_i
2323 rights << right . to_i
2424 end
@@ -36,7 +36,7 @@ def imperative_style(input)
3636def solution ( input )
3737 functional_result = functional_style ( input )
3838 imperative_result = imperative_style ( input )
39- puts " Functional result: #{ functional_result } "
40- puts " Imparative result: #{ imperative_result } "
39+ puts ' Functional result: #{functional_result}'
40+ puts ' Imparative result: #{imperative_result}'
4141 return functional_result
4242end
Original file line number Diff line number Diff line change 11def functional_style ( input )
2- lefts , rights = input . split ( " \n " ) . map { |line | line . split ( ' ' ) } . transpose
2+ lefts , rights = input . split ( '\n' ) . map { |line | line . split ( ' ' ) } . transpose
33
44 counts = rights . tally
55
@@ -9,13 +9,13 @@ def functional_style(input)
99end
1010
1111def imperative_style ( input )
12- lines = input . split ( " \n " )
12+ lines = input . split ( '\n' )
1313
1414 lefts = [ ]
1515 rights = Hash . new ( 0 )
1616
1717 for line in lines
18- left , right = line . split ( " " )
18+ left , right = line . split ( ' ' )
1919 lefts << left
2020 rights [ right ] += 1
2121 end
@@ -31,7 +31,7 @@ def imperative_style(input)
3131def solution ( input )
3232 functional_result = functional_style ( input )
3333 imperative_result = imperative_style ( input )
34- puts " Functional result: #{ functional_result } "
35- puts " Imparative result: #{ imperative_result } "
34+ puts ' Functional result: #{functional_result}'
35+ puts ' Imparative result: #{imperative_result}'
3636 return functional_result
3737end
You can’t perform that action at this time.
0 commit comments