Skip to content

Commit

Permalink
Merge pull request #245 from synthead/add-rubocop
Browse files Browse the repository at this point in the history
Add Rubocop CI job and fix lint offences
  • Loading branch information
synthead authored Dec 25, 2022
2 parents 49299fe + 080e6b8 commit cefa8d1
Show file tree
Hide file tree
Showing 57 changed files with 225 additions and 173 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ jobs:
bundler-cache: true
- run: bundle exec rspec --format=documentation

rubocop:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- run: bundle exec rubocop

yard_junk:
runs-on: ubuntu-latest
steps:
Expand Down
6 changes: 6 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
inherit_gem:
rubocop-github:
- config/default.yml

AllCops:
NewCops: enable
35 changes: 35 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,24 @@ GEM
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
backports (3.23.0)
concurrent-ruby (1.1.10)
crc (0.4.2)
diff-lcs (1.5.0)
ffi (1.15.5)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
json (2.6.3)
mdb (0.5.0)
minitest (5.16.3)
parallel (1.22.1)
parser (3.1.3.0)
ast (~> 2.4.1)
rack (3.0.2)
rainbow (3.1.1)
regexp_parser (2.6.1)
rexml (3.2.5)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
Expand All @@ -40,10 +48,35 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
rubocop (1.41.1)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.2.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.23.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.24.0)
parser (>= 3.1.1.0)
rubocop-github (0.20.0)
rubocop (>= 1.37)
rubocop-performance (>= 1.15)
rubocop-rails (>= 2.17)
rubocop-performance (1.15.2)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
rubocop-rails (2.17.4)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
ruby-progressbar (1.11.0)
rubyserial (0.6.0)
ffi (~> 1.9, >= 1.9.3)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
unicode-display_width (2.3.0)
webrick (1.7.0)
yard (0.9.28)
webrick (~> 1.7.0)
Expand All @@ -57,6 +90,8 @@ PLATFORMS

DEPENDENCIES
rspec (~> 3.11.0)
rubocop (~> 1.41.1)
rubocop-github (~> 0.20.0)
timex_datalink_client!
tzinfo (~> 2.0.5)
yard-junk (~> 0.0.9)
Expand Down
10 changes: 5 additions & 5 deletions lib/timex_datalink_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ def write
#
# @return [Array<Array<Integer>>] Two-dimensional array of integers that represent bytes.
def packets
models.map(&:packets).flatten(1)
models.flat_map(&:packets)
end

private

def notebook_adapter
@notebook_adapter ||= NotebookAdapter.new(
serial_device: serial_device,
byte_sleep: byte_sleep,
packet_sleep: packet_sleep,
verbose: verbose
serial_device:,
byte_sleep:,
packet_sleep:,
verbose:
)
end
end
2 changes: 1 addition & 1 deletion lib/timex_datalink_client/helpers/char_encoders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def chars_for(string_chars, char_map: CHARS, length: nil, pad: false)
end

def eeprom_chars_for(string_chars, length: 31)
chars = chars_for(string_chars, char_map: EEPROM_CHARS, length: length).append(EEPROM_TERMINATOR)
chars = chars_for(string_chars, char_map: EEPROM_CHARS, length:).append(EEPROM_TERMINATOR)

packed_int = chars.each_with_index.sum do |char, index|
char << (6 * index)
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/timex_datalink_client/notebook_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

subject(:notebook_adapter) do
described_class.new(
serial_device: serial_device,
byte_sleep: byte_sleep,
packet_sleep: packet_sleep,
verbose: verbose
serial_device:,
byte_sleep:,
packet_sleep:,
verbose:
)
end

Expand Down
12 changes: 6 additions & 6 deletions spec/lib/timex_datalink_client/protocol_1/alarm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

let(:alarm) do
described_class.new(
number: number,
audible: audible,
time: time,
message: message,
month: month,
day: day
number:,
audible:,
time:,
message:,
month:,
day:
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

let(:anniversary_instance) do
described_class.new(
time: time,
anniversary: anniversary
time:,
anniversary:
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

let(:appointment) do
described_class.new(
time: time,
message: message
time:,
message:
)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/timex_datalink_client/protocol_1/eeprom/list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

let(:list) do
described_class.new(
list_entry: list_entry,
priority: priority
list_entry:,
priority:
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

let(:phone_number) do
described_class.new(
name: name,
number: number,
type: type
name:,
number:,
type:
)
end

Expand Down
10 changes: 5 additions & 5 deletions spec/lib/timex_datalink_client/protocol_1/eeprom_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@

let(:eeprom) do
described_class.new(
appointments: appointments,
anniversaries: anniversaries,
phone_numbers: phone_numbers,
lists: lists,
appointment_notification: appointment_notification
appointments:,
anniversaries:,
phone_numbers:,
lists:,
appointment_notification:
)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/timex_datalink_client/protocol_1/sync_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

describe TimexDatalinkClient::Protocol1::Sync do
let(:length) { 200 }
let(:sync) { described_class.new(length: length) }
let(:sync) { described_class.new(length:) }

describe "#packets" do
subject(:packets) { sync.packets }
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/timex_datalink_client/protocol_1/time_name_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

let(:time_instance) do
described_class.new(
zone: zone,
name: name
zone:,
name:
)
end

Expand Down
6 changes: 3 additions & 3 deletions spec/lib/timex_datalink_client/protocol_1/time_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

let(:time_instance) do
described_class.new(
zone: zone,
is_24h: is_24h,
time: time
zone:,
is_24h:,
time:
)
end

Expand Down
8 changes: 4 additions & 4 deletions spec/lib/timex_datalink_client/protocol_3/alarm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

let(:alarm) do
described_class.new(
number: number,
audible: audible,
time: time,
message: message
number:,
audible:,
time:,
message:
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

let(:anniversary_instance) do
described_class.new(
time: time,
anniversary: anniversary
time:,
anniversary:
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

let(:appointment) do
described_class.new(
time: time,
message: message
time:,
message:
)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/timex_datalink_client/protocol_3/eeprom/list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

let(:list) do
described_class.new(
list_entry: list_entry,
priority: priority
list_entry:,
priority:
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

let(:phone_number) do
described_class.new(
name: name,
number: number,
type: type
name:,
number:,
type:
)
end

Expand Down
10 changes: 5 additions & 5 deletions spec/lib/timex_datalink_client/protocol_3/eeprom_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@

let(:eeprom) do
described_class.new(
appointments: appointments,
anniversaries: anniversaries,
phone_numbers: phone_numbers,
lists: lists,
appointment_notification: appointment_notification
appointments:,
anniversaries:,
phone_numbers:,
lists:,
appointment_notification:
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

let(:sound_options) do
described_class.new(
hourly_chime: hourly_chime,
button_beep: button_beep
hourly_chime:,
button_beep:
)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/timex_datalink_client/protocol_3/sound_theme_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
describe TimexDatalinkClient::Protocol3::SoundTheme do
let(:sound_theme) do
described_class.new(
sound_theme_data: sound_theme_data,
spc_file: spc_file
sound_theme_data:,
spc_file:
)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/timex_datalink_client/protocol_3/sync_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

describe TimexDatalinkClient::Protocol3::Sync do
let(:length) { 200 }
let(:sync) { described_class.new(length: length) }
let(:sync) { described_class.new(length:) }

describe "#packets" do
subject(:packets) { sync.packets }
Expand Down
10 changes: 5 additions & 5 deletions spec/lib/timex_datalink_client/protocol_3/time_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

let(:time_instance) do
described_class.new(
zone: zone,
is_24h: is_24h,
date_format: date_format,
time: time,
name: name
zone:,
is_24h:,
date_format:,
time:,
name:
)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/lib/timex_datalink_client/protocol_3/wrist_app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
describe TimexDatalinkClient::Protocol3::WristApp do
let(:wrist_app) do
described_class.new(
wrist_app_data: wrist_app_data,
zap_file: zap_file
wrist_app_data:,
zap_file:
)
end

Expand Down
Loading

0 comments on commit cefa8d1

Please sign in to comment.