diff options
| author | Gautham Goli | 2017-06-16 19:44:14 +0530 |
|---|---|---|
| committer | Gautham Goli | 2017-06-16 19:45:16 +0530 |
| commit | 0e1c88e7aefb93a8e2cc927fa9a4e903ac015c57 (patch) | |
| tree | 0c91ca4b66538b4d179fd7877fc2e2caf5368a48 /Library/Homebrew/rubocops/extend | |
| parent | 77da75e7d6ecc2ca749eb939d8e24ad9e3dfc5e1 (diff) | |
| download | brew-0e1c88e7aefb93a8e2cc927fa9a4e903ac015c57.tar.bz2 | |
Refactor Checksum cop to add autocorrect method
Diffstat (limited to 'Library/Homebrew/rubocops/extend')
| -rw-r--r-- | Library/Homebrew/rubocops/extend/formula_cop.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Library/Homebrew/rubocops/extend/formula_cop.rb b/Library/Homebrew/rubocops/extend/formula_cop.rb index 98280841c..439fde6a5 100644 --- a/Library/Homebrew/rubocops/extend/formula_cop.rb +++ b/Library/Homebrew/rubocops/extend/formula_cop.rb @@ -277,6 +277,17 @@ module RuboCop end end + # Returns the sha256 str node given a sha256 call node + def get_checksum_node(call) + return if parameters(call).empty? || parameters(call).nil? + if parameters(call).first.str_type? + parameters(call).first + # sha256 is passed as a key-value pair in bottle blocks + elsif parameters(call).first.hash_type? + parameters(call).first.keys.first + end + end + # Returns the begin position of the node's line in source code def line_start_column(node) node.source_range.source_buffer.line_range(node.loc.line).begin_pos |
