Skip to content

Commit

Permalink
Fix credo issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pojiro committed Sep 4, 2024
1 parent d697310 commit 2bdcdcc
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/modbuzz/pdu/helper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ defmodule Modbuzz.PDU.Helper do
"`Modbuzz.PDU` implementation for #{type}."
end

def module_one_line_doc2(module) when is_atom(module) do
["Modbuzz", "PDU2", modbus_function, type] = Module.split(module)
"#{type} struct for #{modbus_function}."
end

@spec to_boolean(0xFF00 | 0x0000) :: boolean()
def to_boolean(0xFF00), do: true
def to_boolean(0x0000), do: false
Expand Down
6 changes: 6 additions & 0 deletions lib/modbuzz/pdu2/read_coils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ defmodule Modbuzz.PDU2.ReadCoils do
@moduledoc false

defmodule Req do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
starting_address: 0x0000..0xFFFF,
quantity_of_coils: 1..2000
Expand Down Expand Up @@ -36,6 +38,8 @@ defmodule Modbuzz.PDU2.ReadCoils do
end

defmodule Res do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
byte_count: byte(),
coil_status: [] | [boolean()]
Expand Down Expand Up @@ -86,6 +90,8 @@ defmodule Modbuzz.PDU2.ReadCoils do
end

defmodule Err do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
exception_code: 0x01..0x04
}
Expand Down
6 changes: 6 additions & 0 deletions lib/modbuzz/pdu2/read_discrete_inputs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ defmodule Modbuzz.PDU2.ReadDiscreteInputs do
@moduledoc false

defmodule Req do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
starting_address: 0x0000..0xFFFF,
quantity_of_inputs: 1..2000
Expand Down Expand Up @@ -36,6 +38,8 @@ defmodule Modbuzz.PDU2.ReadDiscreteInputs do
end

defmodule Res do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
byte_count: byte(),
input_status: [] | [boolean()]
Expand Down Expand Up @@ -86,6 +90,8 @@ defmodule Modbuzz.PDU2.ReadDiscreteInputs do
end

defmodule Err do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
exception_code: 0x01..0x04
}
Expand Down
6 changes: 6 additions & 0 deletions lib/modbuzz/pdu2/read_holding_registers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ defmodule Modbuzz.PDU2.ReadHoldingRegisters do
@moduledoc false

defmodule Req do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
starting_address: 0x0000..0xFFFF,
quantity_of_registers: 1..125
Expand Down Expand Up @@ -40,6 +42,8 @@ defmodule Modbuzz.PDU2.ReadHoldingRegisters do
end

defmodule Res do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
byte_count: byte(),
register_value: 0x0000..0xFFFF
Expand Down Expand Up @@ -82,6 +86,8 @@ defmodule Modbuzz.PDU2.ReadHoldingRegisters do
end

defmodule Err do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
exception_code: 0x01..0x04
}
Expand Down
6 changes: 6 additions & 0 deletions lib/modbuzz/pdu2/read_input_registers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ defmodule Modbuzz.PDU2.ReadInputRegisters do
@moduledoc false

defmodule Req do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
starting_address: 0x0000..0xFFFF,
quantity_of_input_registers: 0x0001..0x007D
Expand Down Expand Up @@ -43,6 +45,8 @@ defmodule Modbuzz.PDU2.ReadInputRegisters do
end

defmodule Res do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
byte_count: byte(),
input_registers: [0x0000..0xFFFF]
Expand Down Expand Up @@ -85,6 +89,8 @@ defmodule Modbuzz.PDU2.ReadInputRegisters do
end

defmodule Err do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
exception_code: 0x01..0x04
}
Expand Down
6 changes: 6 additions & 0 deletions lib/modbuzz/pdu2/write_multiple_coils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ defmodule Modbuzz.PDU2.WriteMultipleCoils do
@moduledoc false

defmodule Req do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
starting_address: 0x0000..0xFFFF,
quantity_of_outputs: 0x0001..0x07B0,
Expand Down Expand Up @@ -60,6 +62,8 @@ defmodule Modbuzz.PDU2.WriteMultipleCoils do
end

defmodule Res do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
starting_address: 0x0000..0xFFFF,
quantity_of_outputs: 0x0001..0x07B0
Expand Down Expand Up @@ -97,6 +101,8 @@ defmodule Modbuzz.PDU2.WriteMultipleCoils do
end

defmodule Err do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
exception_code: 0x01..0x04
}
Expand Down
6 changes: 6 additions & 0 deletions lib/modbuzz/pdu2/write_multiple_registers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ defmodule Modbuzz.PDU2.WriteMultipleRegisters do
@moduledoc false

defmodule Req do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
starting_address: 0x0000..0xFFFF,
quantity_of_registers: 0x0001..0x007B,
Expand Down Expand Up @@ -60,6 +62,8 @@ defmodule Modbuzz.PDU2.WriteMultipleRegisters do
end

defmodule Res do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
starting_address: 0x0000..0xFFFF,
quantity_of_registers: 0x0001..0x007B
Expand Down Expand Up @@ -101,6 +105,8 @@ defmodule Modbuzz.PDU2.WriteMultipleRegisters do
end

defmodule Err do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
exception_code: 0x01..0x04
}
Expand Down
6 changes: 6 additions & 0 deletions lib/modbuzz/pdu2/write_single_coil.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ defmodule Modbuzz.PDU2.WriteSingleCoil do
@moduledoc false

defmodule Req do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
output_address: 0x0000..0xFFFF,
output_value: boolean()
Expand Down Expand Up @@ -38,6 +40,8 @@ defmodule Modbuzz.PDU2.WriteSingleCoil do
end

defmodule Res do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
output_address: 0x0000..0xFFFF,
output_value: boolean()
Expand Down Expand Up @@ -80,6 +84,8 @@ defmodule Modbuzz.PDU2.WriteSingleCoil do
end

defmodule Err do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
exception_code: 0x01..0x04
}
Expand Down
6 changes: 6 additions & 0 deletions lib/modbuzz/pdu2/write_single_register.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ defmodule Modbuzz.PDU2.WriteSingleRegister do
@moduledoc false

defmodule Req do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
register_address: 0x0000..0xFFFF,
register_value: 0x0000..0xFFFF
Expand Down Expand Up @@ -36,6 +38,8 @@ defmodule Modbuzz.PDU2.WriteSingleRegister do
end

defmodule Res do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
register_address: 0x0000..0xFFFF,
register_value: 0x0000..0xFFFF
Expand Down Expand Up @@ -73,6 +77,8 @@ defmodule Modbuzz.PDU2.WriteSingleRegister do
end

defmodule Err do
@moduledoc Modbuzz.PDU.Helper.module_one_line_doc2(__MODULE__)

@type t :: %__MODULE__{
exception_code: 0x01..0x04
}
Expand Down

0 comments on commit 2bdcdcc

Please sign in to comment.