-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: add elvis linter #502
base: master
Are you sure you want to change the base?
ci: add elvis linter #502
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: "Elvis Linter" | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: ["**"] | ||
jobs: | ||
linter: | ||
runs-on: self-hosted | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: "recursive" | ||
- name: lint | ||
run: elvis rock --config config/elvis.config |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
-module(ar_arql_middleware). | ||
-behavior(cowboy_middleware). | ||
-behaviour(cowboy_middleware). | ||
|
||
-export([execute/2]). | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,8 +52,7 @@ block_field_size_limit(B) -> | |
Check = (byte_size(B#block.nonce) =< 512) and | ||
(byte_size(B#block.previous_block) =< 48) and | ||
(byte_size(integer_to_binary(B#block.timestamp)) =< ?TIMESTAMP_FIELD_SIZE_LIMIT) and | ||
(byte_size(integer_to_binary(B#block.last_retarget)) | ||
=< ?TIMESTAMP_FIELD_SIZE_LIMIT) and | ||
(byte_size(integer_to_binary(B#block.last_retarget)) =< ?TIMESTAMP_FIELD_SIZE_LIMIT) and | ||
(byte_size(integer_to_binary(B#block.diff)) =< DiffBytesLimit) and | ||
(byte_size(integer_to_binary(B#block.height)) =< 20) and | ||
(byte_size(B#block.hash) =< 48) and | ||
|
@@ -249,9 +248,8 @@ compute_next_vdf_difficulty(PrevB) -> | |
{0, 0}, | ||
HistoryPart | ||
), | ||
NewVDFDifficulty = | ||
(VDFIntervalTotal * VDFDifficulty) div IntervalTotal, | ||
EMAVDFDifficulty = (9*VDFDifficulty + NewVDFDifficulty) div 10, | ||
NewVDFDifficulty = (VDFIntervalTotal * VDFDifficulty) div IntervalTotal, | ||
EMAVDFDifficulty = (9 * VDFDifficulty + NewVDFDifficulty) div 10, | ||
?LOG_DEBUG([{event, vdf_difficulty_retarget}, | ||
{height, Height}, | ||
{old_vdf_difficulty, VDFDifficulty}, | ||
|
@@ -484,8 +482,7 @@ generate_block_data_segment_base(B) -> | |
integer_to_binary(ScheduledRateDividend), | ||
integer_to_binary(ScheduledRateDivisor), | ||
integer_to_binary(B#block.packing_2_5_threshold), | ||
integer_to_binary(B#block.strict_data_split_threshold) | ||
| Props | ||
integer_to_binary(B#block.strict_data_split_threshold) | Props | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this an elvis change? Personally I prefer to keep newlines consistent within an operator. For this operator we've made the choice to put each list element on its own line, so I would prefer to also put the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the default rule says that there can't be space on the left side of an operator, this has the effect that we have ValA +
ValB +
ValC. and not ValA
+ ValB
+ ValC personally I'm not trained to read code like thie {
a: 1
,b: 2
,c: 3
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with
or
and think in general commas should be treated differently from math operators for the reason you mention (commas generally bind to the left value, but it's less clear with binary math operators which value they more logically bind to - think of grammar school long addition, in the US we're taught to put the But that said, I retract my original point on the |
||
]; | ||
false -> | ||
Props | ||
|
@@ -514,8 +511,8 @@ generate_block_data_segment_base(B) -> | |
%% of the two recall ranges. | ||
get_recall_range(H0, PartitionNumber, PartitionUpperBound) -> | ||
RecallRange1Offset = binary:decode_unsigned(binary:part(H0, 0, 8), big), | ||
RecallRange1Start = PartitionNumber * ?PARTITION_SIZE | ||
+ RecallRange1Offset rem min(?PARTITION_SIZE, PartitionUpperBound), | ||
RecallRange1Start = PartitionNumber * ?PARTITION_SIZE + | ||
RecallRange1Offset rem min(?PARTITION_SIZE, PartitionUpperBound), | ||
RecallRange2Start = binary:decode_unsigned(H0, big) rem PartitionUpperBound, | ||
{RecallRange1Start, RecallRange2Start}. | ||
|
||
|
@@ -584,8 +581,7 @@ generate_size_tagged_list_from_txs(TXs, Height) -> | |
End = Pos + DataSize, | ||
case Height >= ar_fork:height_2_5() of | ||
true -> | ||
Padding = ar_tx:get_weave_size_increase(DataSize, Height) | ||
- DataSize, | ||
Padding = ar_tx:get_weave_size_increase(DataSize, Height) - DataSize, | ||
%% Encode the padding information in the Merkle tree. | ||
case Padding > 0 of | ||
true -> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we remove spaces here, but not here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is a good question, I believe the complaint was just about the parentheses and I did more than was needed to satisfy this lint rule