Skip to content
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

[WIP] Rubocop all the things #22919

Open
wants to merge 205 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
205 commits
Select commit Hold shift + click to select a range
3ab431e
rubocop -a --only Bundler/OrderedGems
Fryguy Feb 29, 2024
a2b0ede
rubocop -a --only Layout/ArgumentAlignment
Fryguy Feb 29, 2024
e93c342
rubocop -a --only Layout/ArrayAlignment
Fryguy Feb 29, 2024
c17d08e
rubocop -a --only Layout/BeginEndAlignment
Fryguy Feb 29, 2024
fbeae64
rubocop -a --only Layout/BlockAlignment
Fryguy Feb 29, 2024
60c7c36
rubocop -a --only Layout/BlockEndNewline
Fryguy Feb 29, 2024
c5085c6
rubocop -a --only Layout/ClosingHeredocIndentation
Fryguy Feb 29, 2024
5c11e0e
rubocop -a --only Layout/ClosingParenthesisIndentation
Fryguy Feb 29, 2024
b30e83e
rubocop -a --only Layout/CommentIndentation
Fryguy Feb 29, 2024
cdea9bb
rubocop -a --only Layout/EmptyComment
Fryguy Feb 29, 2024
66fc796
rubocop -a --only Layout/EmptyLineAfterGuardClause
Fryguy Feb 29, 2024
56f86c6
rubocop -a --only Layout/EmptyLineAfterMagicComment
Fryguy Feb 29, 2024
9673ced
rubocop -a --only Layout/EmptyLineBetweenDefs
Fryguy Feb 29, 2024
deda507
rubocop -a --only Layout/EmptyLines
Fryguy Feb 29, 2024
0c7dec9
rubocop -a --only Layout/EmptyLinesAroundAttributeAccessor
Fryguy Feb 29, 2024
db24a23
rubocop -a --only Layout/EmptyLinesAroundBeginBody
Fryguy Feb 29, 2024
ef64dc8
rubocop -a --only Layout/EmptyLinesAroundBlockBody
Fryguy Feb 29, 2024
e6aee5c
rubocop -a --only Layout/EmptyLinesAroundClassBody
Fryguy Feb 29, 2024
0359d19
rubocop -a --only Layout/EmptyLinesAroundExceptionHandlingKeywords
Fryguy Feb 29, 2024
7758303
rubocop -a --only Layout/EmptyLinesAroundMethodBody
Fryguy Feb 29, 2024
35f894b
rubocop -a --only Layout/EmptyLinesAroundModuleBody
Fryguy Feb 29, 2024
0125221
rubocop -a --only Layout/ExtraSpacing
Fryguy Feb 29, 2024
a01a06d
rubocop -a --only Layout/FirstArgumentIndentation
Fryguy Feb 29, 2024
15b59fe
rubocop -a --only Layout/FirstArrayElementIndentation
Fryguy Feb 29, 2024
473778e
rubocop -a --only Layout/FirstHashElementIndentation
Fryguy Feb 29, 2024
4d42d57
rubocop -a --only Layout/HashAlignment
Fryguy Feb 29, 2024
a68ec06
rubocop -a --only Layout/HeredocIndentation
Fryguy Feb 29, 2024
e43c15d
rubocop -a --only Layout/IndentationConsistency
Fryguy Feb 29, 2024
6008a35
rubocop -a --only Layout/IndentationStyle
Fryguy Feb 29, 2024
8f46ac6
rubocop -a --only Layout/IndentationWidth
Fryguy Feb 29, 2024
9c04d6c
rubocop -a --only Layout/LeadingCommentSpace
Fryguy Feb 29, 2024
48e9936
rubocop -a --only Layout/LineContinuationLeadingSpace
Fryguy Feb 29, 2024
d132a70
rubocop -a --only Layout/LineContinuationSpacing
Fryguy Feb 29, 2024
0d3785e
rubocop -a --only Layout/LineEndStringConcatenationIndentation
Fryguy Feb 29, 2024
c15bd2f
rubocop -a --only Layout/MultilineArrayBraceLayout
Fryguy Feb 29, 2024
40e74f6
rubocop -a --only Layout/MultilineBlockLayout
Fryguy Feb 29, 2024
6d6f9a9
rubocop -a --only Layout/MultilineHashBraceLayout
Fryguy Feb 29, 2024
11c5a78
rubocop -a --only Layout/MultilineMethodCallBraceLayout
Fryguy Feb 29, 2024
d01a76d
rubocop -a --only Layout/MultilineMethodCallIndentation
Fryguy Feb 29, 2024
96d5e55
rubocop -a --only Layout/MultilineOperationIndentation
Fryguy Feb 29, 2024
be5a973
rubocop -a --only Layout/SpaceAfterComma
Fryguy Feb 29, 2024
5d7e38b
rubocop -a --only Layout/SpaceAroundMethodCallOperator
Fryguy Feb 29, 2024
c1b6513
rubocop -a --only Layout/SpaceAroundOperators
Fryguy Feb 29, 2024
551ec01
rubocop -a --only Layout/SpaceBeforeBlockBraces
Fryguy Feb 29, 2024
ec330e0
rubocop -a --only Layout/SpaceBeforeBrackets
Fryguy Feb 29, 2024
2bf370b
rubocop -a --only Layout/SpaceBeforeComma
Fryguy Feb 29, 2024
1c154b4
rubocop -a --only Layout/SpaceInsideArrayLiteralBrackets
Fryguy Feb 29, 2024
5e820dd
rubocop -a --only Layout/SpaceInsideArrayPercentLiteral
Fryguy Feb 29, 2024
6205af5
rubocop -a --only Layout/SpaceInsideBlockBraces
Fryguy Feb 29, 2024
42880c3
rubocop -a --only Layout/SpaceInsideHashLiteralBraces
Fryguy Feb 29, 2024
a5117d0
rubocop -a --only Layout/SpaceInsidePercentLiteralDelimiters
Fryguy Feb 29, 2024
4ea944d
rubocop -a --only Layout/SpaceInsideStringInterpolation
Fryguy Feb 29, 2024
d9dd670
rubocop -a --only Layout/TrailingEmptyLines
Fryguy Feb 29, 2024
35d5d82
rubocop -a --only Layout/TrailingWhitespace
Fryguy Feb 29, 2024
22cca16
rubocop -a --only Lint/AmbiguousBlockAssociation
Fryguy Feb 29, 2024
00679c5
rubocop -a --only Lint/AmbiguousOperator
Fryguy Feb 29, 2024
75a6ec5
rubocop -a --only Lint/AmbiguousOperatorPrecedence
Fryguy Feb 29, 2024
e880c29
rubocop -a --only Lint/ErbNewArguments
Fryguy Feb 29, 2024
a233789
rubocop -a --only Lint/LambdaWithoutLiteralBlock
Fryguy Feb 29, 2024
3391d7b
rubocop -a --only Lint/ParenthesesAsGroupedExpression
Fryguy Feb 29, 2024
f91cce3
rubocop -a --only Lint/RedundantSplatExpansion
Fryguy Feb 29, 2024
74fd130
rubocop -a --only Lint/RedundantStringCoercion
Fryguy Feb 29, 2024
dc68e37
rubocop -a --only Lint/SendWithMixinArgument
Fryguy Feb 29, 2024
29ffeeb
rubocop -a --only Lint/SymbolConversion
Fryguy Feb 29, 2024
3377702
rubocop -a --only Lint/ToJSON
Fryguy Feb 29, 2024
75ebb12
rubocop -a --only Lint/UnusedBlockArgument
Fryguy Feb 29, 2024
8c6b978
rubocop -a --only Lint/UnusedMethodArgument
Fryguy Feb 29, 2024
29fd459
rubocop -a --only Lint/UriRegexp
Fryguy Feb 29, 2024
e15050f
rubocop -a --only Lint/UselessAccessModifier
Fryguy Feb 29, 2024
85a62ff
rubocop -a --only Lint/Void
Fryguy Feb 29, 2024
1d086e1
rubocop -a --only Naming/BinaryOperatorParameterName
Fryguy Feb 29, 2024
d347e4a
rubocop -a --only Performance/BindCall
Fryguy Feb 29, 2024
b5d6ef9
rubocop -a --only Performance/BlockGivenWithExplicitBlock
Fryguy Feb 29, 2024
a64577f
rubocop -a --only Performance/Caller
Fryguy Feb 29, 2024
7c1d63e
rubocop -a --only Performance/CompareWithBlock
Fryguy Feb 29, 2024
863917e
rubocop -a --only Performance/ConstantRegexp
Fryguy Feb 29, 2024
4876626
rubocop -a --only Performance/RedundantBlockCall
Fryguy Feb 29, 2024
fa59f02
rubocop -a --only Performance/RedundantMatch
Fryguy Feb 29, 2024
ac4798a
rubocop -a --only Performance/RegexpMatch
Fryguy Feb 29, 2024
dd36bca
rubocop -a --only Performance/StringIdentifierArgument
Fryguy Feb 29, 2024
9aa955a
rubocop -a --only Performance/StringReplacement
Fryguy Feb 29, 2024
53aa34a
rubocop -a --only Rails/ActiveRecordCallbacksOrder
Fryguy Feb 29, 2024
ea3424f
rubocop -a --only Rails/Delegate
Fryguy Feb 29, 2024
e828324
rubocop -a --only Rails/DuplicateAssociation
Fryguy Feb 29, 2024
67728f6
rubocop -a --only Rails/DurationArithmetic
Fryguy Feb 29, 2024
ae737cb
rubocop -a --only Rails/FilePath
Fryguy Feb 29, 2024
af8745c
rubocop -a --only Rails/FindBy
Fryguy Feb 29, 2024
5094c33
rubocop -a --only Rails/IndexBy
Fryguy Feb 29, 2024
225816b
rubocop -a --only Rails/IndexWith
Fryguy Feb 29, 2024
26da9f3
rubocop -a --only Rails/PluralizationGrammar
Fryguy Feb 29, 2024
893cdc6
rubocop -a --only Rails/Presence
Fryguy Feb 29, 2024
679b16a
rubocop -a --only Rails/Present
Fryguy Feb 29, 2024
c009644
rubocop -a --only Rails/RedundantForeignKey
Fryguy Feb 29, 2024
342cca2
rubocop -a --only Rails/RootPublicPath
Fryguy Feb 29, 2024
6a324e5
rubocop -a --only Rails/SafeNavigation
Fryguy Feb 29, 2024
35dd991
rubocop -a --only Rails/StripHeredoc
Fryguy Feb 29, 2024
c8ed579
rubocop -a --only Rails/TopLevelHashWithIndifferentAccess
Fryguy Feb 29, 2024
efe9291
rubocop -a --only Rails/Validation
Fryguy Feb 29, 2024
0a05379
rubocop -a --only Rails/WhereNot
Fryguy Feb 29, 2024
759aebe
rubocop -a --only Style/AccessorGrouping
Fryguy Feb 29, 2024
d662a8d
rubocop -a --only Style/Alias
Fryguy Feb 29, 2024
c5eca7e
rubocop -a --only Style/ArgumentsForwarding
Fryguy Feb 29, 2024
ee3bea6
rubocop -a --only Style/BarePercentLiterals
Fryguy Feb 29, 2024
4bfceb2
rubocop -a --only Style/BlockComments
Fryguy Feb 29, 2024
b068888
rubocop -a --only Style/BlockDelimiters
Fryguy Feb 29, 2024
8aef328
rubocop -a --only Style/CaseEquality
Fryguy Feb 29, 2024
79c240f
rubocop -a --only Style/ClassCheck
Fryguy Feb 29, 2024
c4278ba
rubocop -a --only Style/ClassEqualityComparison
Fryguy Feb 29, 2024
9e75cd2
rubocop -a --only Style/ColonMethodCall
Fryguy Feb 29, 2024
3c810b0
rubocop -a --only Style/CommentAnnotation
Fryguy Feb 29, 2024
c11d1ea
rubocop -a --only Style/ConditionalAssignment
Fryguy Feb 29, 2024
3e328f7
rubocop -a --only Style/EachForSimpleLoop
Fryguy Feb 29, 2024
597cfc3
rubocop -a --only Style/EachWithObject
Fryguy Feb 29, 2024
2c5fc7a
rubocop -a --only Style/EmptyCaseCondition
Fryguy Feb 29, 2024
6d7da75
rubocop -a --only Style/EmptyLiteral
Fryguy Feb 29, 2024
b4f7f30
rubocop -a --only Style/EvalWithLocation
Fryguy Feb 29, 2024
45e3430
rubocop -a --only Style/ExpandPathArguments
Fryguy Feb 29, 2024
ae7f451
rubocop -a --only Style/ExplicitBlockArgument
Fryguy Feb 29, 2024
c334dfc
rubocop -a --only Style/FetchEnvVar
Fryguy Feb 29, 2024
434ba42
rubocop -a --only Style/FileWrite
Fryguy Feb 29, 2024
5a6ec33
rubocop -a --only Style/FormatString
Fryguy Feb 29, 2024
28fc6df
rubocop -a --only Style/HashAsLastArrayItem
Fryguy Feb 29, 2024
a1abb42
rubocop -a --only Style/HashSyntax
Fryguy Feb 29, 2024
b9b30e7
rubocop -a --only Style/IfInsideElse
Fryguy Feb 29, 2024
d6df9eb
rubocop -a --only Style/Lambda
Fryguy Feb 29, 2024
c09dc36
rubocop -a --only Style/MethodCallWithArgsParentheses
Fryguy Feb 29, 2024
324c8b7
rubocop -a --only Style/MultilineIfModifier
Fryguy Feb 29, 2024
d513b35
rubocop -a --only Style/MultilineMemoization
Fryguy Feb 29, 2024
8e02fdc
rubocop -a --only Style/MultilineTernaryOperator
Fryguy Feb 29, 2024
8cc3a47
rubocop -a --only Style/MultilineWhenThen
Fryguy Feb 29, 2024
4949aa4
rubocop -a --only Style/MultipleComparison
Fryguy Feb 29, 2024
6fd83d0
rubocop -a --only Style/NestedParenthesizedCalls
Fryguy Feb 29, 2024
1e8f1e1
rubocop -a --only Style/NestedTernaryOperator
Fryguy Feb 29, 2024
3c1ca73
rubocop -a --only Style/Next
Fryguy Feb 29, 2024
973925d
rubocop -a --only Style/NumericLiteralPrefix
Fryguy Feb 29, 2024
a527752
rubocop -a --only Style/OperatorMethodCall
Fryguy Feb 29, 2024
2f6e83a
rubocop -a --only Style/OrAssignment
Fryguy Feb 29, 2024
fe4a742
rubocop -a --only Style/ParenthesesAroundCondition
Fryguy Feb 29, 2024
916593f
rubocop -a --only Style/PercentLiteralDelimiters
Fryguy Feb 29, 2024
38d8786
rubocop -a --only Style/RaiseArgs
Fryguy Feb 29, 2024
0f170fb
rubocop -a --only Style/RandomWithOffset
Fryguy Feb 29, 2024
01e3107
rubocop -a --only Style/RedundantArrayConstructor
Fryguy Feb 29, 2024
b16b9ee
rubocop -a --only Style/RedundantAssignment
Fryguy Feb 29, 2024
55758cf
rubocop -a --only Style/RedundantBegin
Fryguy Feb 29, 2024
f7c9cb8
rubocop -a --only Style/RedundantCondition
Fryguy Feb 29, 2024
fe9f154
rubocop -a --only Style/RedundantConstantBase
Fryguy Feb 29, 2024
ccdcec2
rubocop -a --only Style/RedundantCurrentDirectoryInPath
Fryguy Feb 29, 2024
700ce74
rubocop -a --only Style/RedundantFileExtensionInRequire
Fryguy Feb 29, 2024
02fff1a
rubocop -a --only Style/RedundantFilterChain
Fryguy Feb 29, 2024
bb2deb4
rubocop -a --only Style/RedundantFreeze
Fryguy Feb 29, 2024
95f2155
rubocop -a --only Style/RedundantLineContinuation
Fryguy Feb 29, 2024
e535510
rubocop -a --only Style/RedundantParentheses
Fryguy Feb 29, 2024
0623866
rubocop -a --only Style/RedundantRegexpArgument
Fryguy Feb 29, 2024
bf11339
rubocop -a --only Style/RedundantRegexpEscape
Fryguy Feb 29, 2024
c08a056
rubocop -a --only Style/RedundantReturn
Fryguy Feb 29, 2024
1a9a4b5
rubocop -a --only Style/RedundantSelf
Fryguy Feb 29, 2024
13d9a58
rubocop -a --only Style/RedundantSelfAssignmentBranch
Fryguy Feb 29, 2024
e0813a1
rubocop -a --only Style/RedundantStringEscape
Fryguy Feb 29, 2024
82ac784
rubocop -a --only Style/RescueStandardError
Fryguy Feb 29, 2024
41e453a
rubocop -a --only Style/SingleLineMethods
Fryguy Feb 29, 2024
c81a486
rubocop -a --only Style/SoleNestedConditional
Fryguy Feb 29, 2024
e9ce040
rubocop -a --only Style/StderrPuts
Fryguy Feb 29, 2024
ba3704a
rubocop -a --only Style/TernaryParentheses
Fryguy Feb 29, 2024
deb6ca4
rubocop -a --only Style/TrailingCommaInArguments
Fryguy Feb 29, 2024
eb09596
rubocop -a --only Style/TrivialAccessors
Fryguy Feb 29, 2024
ba869ee
rubocop -a --only Style/UnlessElse
Fryguy Feb 29, 2024
625dfb4
rubocop -a --only Style/UnpackFirst
Fryguy Feb 29, 2024
1c50c5b
rubocop -a --only Layout/ArgumentAlignment
Fryguy Feb 29, 2024
548bde0
rubocop -a --only Layout/ArrayAlignment
Fryguy Feb 29, 2024
2de05c8
rubocop -a --only Layout/AssignmentIndentation
Fryguy Feb 29, 2024
891d2c6
rubocop -a --only Layout/BlockAlignment
Fryguy Feb 29, 2024
d36675e
rubocop -a --only Layout/CaseIndentation
Fryguy Feb 29, 2024
8a53f18
rubocop -a --only Layout/ClosingParenthesisIndentation
Fryguy Feb 29, 2024
b237fe0
rubocop -a --only Layout/CommentIndentation
Fryguy Feb 29, 2024
0cd8257
rubocop -a --only Layout/ElseAlignment
Fryguy Feb 29, 2024
0c0a6ae
rubocop -a --only Layout/EmptyLineAfterGuardClause
Fryguy Feb 29, 2024
4a2c467
rubocop -a --only Layout/EmptyLineBetweenDefs
Fryguy Feb 29, 2024
16ced30
rubocop -a --only Layout/EmptyLines
Fryguy Feb 29, 2024
eed1448
rubocop -a --only Layout/EmptyLinesAroundClassBody
Fryguy Feb 29, 2024
efa3224
rubocop -a --only Layout/EndAlignment
Fryguy Feb 29, 2024
dd59d35
rubocop -a --only Layout/ExtraSpacing
Fryguy Feb 29, 2024
70db5e7
rubocop -a --only Layout/FirstArgumentIndentation
Fryguy Feb 29, 2024
e98de78
rubocop -a --only Layout/FirstArrayElementIndentation
Fryguy Feb 29, 2024
85a0260
rubocop -a --only Layout/FirstHashElementIndentation
Fryguy Feb 29, 2024
e90092b
rubocop -a --only Layout/HashAlignment
Fryguy Feb 29, 2024
e6f8ed7
rubocop -a --only Layout/HeredocIndentation
Fryguy Feb 29, 2024
7afb463
rubocop -a --only Layout/IndentationConsistency
Fryguy Feb 29, 2024
6f37ffa
rubocop -a --only Layout/IndentationWidth
Fryguy Feb 29, 2024
3b31943
rubocop -a --only Layout/MultilineMethodCallIndentation
Fryguy Feb 29, 2024
2323122
rubocop -a --only Layout/MultilineOperationIndentation
Fryguy Feb 29, 2024
50badb5
rubocop -a --only Layout/SpaceAroundOperators
Fryguy Feb 29, 2024
1e18928
rubocop -a --only Layout/SpaceInsideHashLiteralBraces
Fryguy Feb 29, 2024
155a575
rubocop -a --only Layout/TrailingWhitespace
Fryguy Feb 29, 2024
1327c80
rubocop -a --only Lint/AmbiguousOperator
Fryguy Feb 29, 2024
c9e70bd
rubocop -a --only Lint/ElseLayout
Fryguy Feb 29, 2024
16b498e
rubocop -a --only Lint/UnusedMethodArgument
Fryguy Feb 29, 2024
ae6f512
rubocop -a --only Performance/BlockGivenWithExplicitBlock
Fryguy Feb 29, 2024
065aa2c
rubocop -a --only Rails/IndexBy
Fryguy Feb 29, 2024
8da62b9
rubocop -a --only Rails/IndexWith
Fryguy Feb 29, 2024
d430c26
rubocop -a --only Style/DefWithParentheses
Fryguy Feb 29, 2024
9c15725
rubocop -a --only Style/EmptyElse
Fryguy Feb 29, 2024
4bd50b4
rubocop -a --only Style/FetchEnvVar
Fryguy Feb 29, 2024
4aa31b1
rubocop -a --only Style/ParenthesesAroundCondition
Fryguy Feb 29, 2024
97835c7
rubocop -a --only Style/RedundantAssignment
Fryguy Feb 29, 2024
a0fe6fb
rubocop -a --only Style/Semicolon
Fryguy Feb 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ gem "bootsnap", ">= 1.8.1", :require => false #
gem "bundler", "~> 2.1", ">= 2.1.4", "!= 2.2.10", :require => false
gem "byebug", :require => false
gem "color", "~>1.8"
gem "connection_pool", :require => false # For Dalli
gem "config", "~>2.2", ">=2.2.3", :require => false
gem "connection_pool", :require => false # For Dalli
gem "dalli", "~>3.2.3", :require => false
gem "default_value_for", "~>3.3"
gem "docker-api", "~>1.33.6", :require => false
Expand Down Expand Up @@ -61,9 +61,9 @@ gem "net-ldap", "~>0.16.1", :require => false
gem "net-ping", "~>1.7.4", :require => false
gem "openscap", "~>0.4.8", :require => false
gem "optimist", "~>3.0", :require => false
gem "psych", ">=3.1", :require => false # 3.1 safe_load changed positional to kwargs like aliases: true: https://github.com/ruby/psych/commit/4d4439d6d0adfcbd211ea295779315f1baa7dadd
gem "pg", ">=1.4.1", :require => false
gem "pg-dsn_parser", "~>0.1.1", :require => false
gem "psych", ">=3.1", :require => false # 3.1 safe_load changed positional to kwargs like aliases: true: https://github.com/ruby/psych/commit/4d4439d6d0adfcbd211ea295779315f1baa7dadd
gem "query_relation", "~>0.1.0", :require => false
gem "rack", ">=2.2.6.4", :require => false
gem "rack-attack", "~>6.5.0", :require => false
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require File.expand_path('../config/application', __FILE__)
require File.expand_path('../lib/tasks/evm_rake_helper', __FILE__)
require File.expand_path('config/application', __dir__)
require File.expand_path('lib/tasks/evm_rake_helper', __dir__)

include Rake::DSL
Vmdb::Application.load_tasks
Expand Down
1 change: 1 addition & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def connect

def find_verified_user
return reject_unauthorized_connection unless cookies[:ws_token]

userid = TokenManager.new('ws').token_get_info(cookies[:ws_token], :userid)
User.find_by(:userid => userid.presence) || reject_unauthorized_connection
end
Expand Down
25 changes: 14 additions & 11 deletions app/mailers/generic_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.deliver(method, options = {})
rcpts.each do |rcpt|
rcpt.split(',').each do |to|
options[:to] = to
individual = send(method, options)
individual = send(method, options)
begin
individual.deliver_now
rescue Net::SMTPError
Expand All @@ -41,21 +41,21 @@ def self.deliver(method, options = {})
rescue => e
_log.error("method: #{method} options: #{options} delivery-error #{e}")
end

end

msg
end

def self.deliver_queue(method, options = {})
return unless MiqRegion.my_region.role_assigned?('notifier')

_log.info("starting: method: #{method} args: #{options} ")
options[:attachment] &&= attachment_to_blob(options[:attachment])
MiqQueue.submit_job(
:service => "notifier",
:class_name => name,
:method_name => 'deliver',
:args => [method, options],
:args => [method, options]
)
end

Expand Down Expand Up @@ -95,12 +95,14 @@ def self.blob_to_attachment(attachment)
when String # Actual Body
blob_to_attachment(:attachment => attachment)
when Hash
attachment[:body] ||= begin
blob = BinaryBlob.find(attachment.delete(:attachment_id))
body = blob.binary unless blob.nil?
blob.destroy unless blob.nil?
body
end if attachment[:attachment_id].kind_of?(Numeric)
if attachment[:attachment_id].kind_of?(Numeric)
attachment[:body] ||= begin
blob = BinaryBlob.find(attachment.delete(:attachment_id))
body = blob.binary unless blob.nil?
blob.destroy unless blob.nil?
body
end
end
attachment[:filename] ||= "evm_attachment"
attachment
else
Expand Down Expand Up @@ -162,6 +164,7 @@ def prepare_generic_email(options)
options[:attachment].each do |a|
name = a[:filename]
next if name.nil?

attachments[name] = {:mime_type => a[:content_type], :content => a[:body]}
end
mail(:subject => options[:subject], :to => options[:to], :from => options[:from], :cc => options[:cc], :bcc => options[:bcc], :date => options[:sent_on])
Expand All @@ -172,7 +175,7 @@ def prepare_generic_email(options)
OPTIONAL_SMTP_KEYS = [:enable_starttls_auto, :openssl_verify_mode]
def set_mailer_smtp(evm_settings = nil)
evm_settings ||= ::Settings.smtp
am_settings = {}
am_settings = {}

DESTINATION_SMTP_KEYS.each { |key| am_settings[key] = evm_settings[key] }
am_settings[:address] ||= evm_settings[:host] # vmdb.yml has key :host, ActionMailer expects :address
Expand All @@ -181,7 +184,7 @@ def set_mailer_smtp(evm_settings = nil)
case evm_settings[:authentication].to_s.to_sym
when :none then AUTHENTICATION_SMTP_KEYS.each { |key| am_settings[key] = nil }
when :plain, :login then AUTHENTICATION_SMTP_KEYS.each { |key| am_settings[key] = evm_settings[key] }
else raise ArgumentError, "authentication value #{evm_settings[:authentication].inspect} must be one of: 'none', 'plain', 'login'"
else raise ArgumentError, "authentication value #{evm_settings[:authentication].inspect} must be one of: 'none', 'plain', 'login'"
end

OPTIONAL_SMTP_KEYS.each { |key| am_settings[key] = evm_settings[key] if evm_settings.key?(key) }
Expand Down
12 changes: 6 additions & 6 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def self.xml_to_hashes(xmlNode, findPath, typeName)
nh[:acctid] = nh.delete("#{typeName}id".to_sym)
nh[:acctid] = nil unless nh[:acctid].respond_to?(:to_int) || nh[:acctid].to_s =~ /^-?[0-9]+$/
# Convert to signed integer values for acctid
nh[:acctid] = [nh[:acctid].to_i].pack("I").unpack("i")[0] unless nh[:acctid].nil?
nh[:acctid] = [nh[:acctid].to_i].pack("I").unpack1("i") unless nh[:acctid].nil?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's actually correct - I agree it does look strange though.


# Find the users for this group / groups for this user
nh[:members] = []
Expand All @@ -93,7 +93,7 @@ def with_valid_account_type(valid_account_type)
if accttype == valid_account_type
yield
else
raise _("Cannot call method '%{caller}' on an Account of type '%{type}'") % {:caller => caller[0][/`.*'/][1..-2],
raise _("Cannot call method '%{caller}' on an Account of type '%{type}'") % {:caller => caller(1..1).first[/`.*'/][1..-2],
:type => accttype}
Comment on lines +96 to 97
Copy link
Member

@kbrock kbrock Feb 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this also looks strange to me

maybe this is a performance statement where caller() only builds an array for the line in question so you don't create a large backtrace to throw away most of it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct - this prevents it from returning the entire payload

end
end
Expand Down Expand Up @@ -136,18 +136,18 @@ def remove_all_groups
# FIXME: Why not use .pluralize?
#
def members
send("#{accttype_opposite}s")
send(:"#{accttype_opposite}s")
end

def add_member(member)
send("add_#{accttype_opposite}", member)
send(:"add_#{accttype_opposite}", member)
end

def remove_member(member)
send("remove_#{accttype_opposite}", member)
send(:"remove_#{accttype_opposite}", member)
end

def remove_all_members
send("remove_all_#{accttype_opposite}s")
send(:"remove_all_#{accttype_opposite}s")
end
end
1 change: 1 addition & 0 deletions app/models/advanced_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def self.xml_to_hashes(xml_node, find_path)

el.each_element { |e| result << e.attributes.to_h }
end

result
end
end
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::AutomationManagerConfiguredSystem = ::ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem
AutomationManagerConfiguredSystem = ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem
2 changes: 1 addition & 1 deletion app/models/aliases/ems_automation.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsAutomation = ::ManageIQ::Providers::ExternalAutomationManager
EmsAutomation = ManageIQ::Providers::ExternalAutomationManager
2 changes: 1 addition & 1 deletion app/models/aliases/ems_cloud.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsCloud = ::ManageIQ::Providers::CloudManager
EmsCloud = ManageIQ::Providers::CloudManager
2 changes: 1 addition & 1 deletion app/models/aliases/ems_configuration.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsConfiguration = ::ManageIQ::Providers::ConfigurationManager
EmsConfiguration = ManageIQ::Providers::ConfigurationManager
2 changes: 1 addition & 1 deletion app/models/aliases/ems_infra.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsInfra = ::ManageIQ::Providers::InfraManager
EmsInfra = ManageIQ::Providers::InfraManager
2 changes: 1 addition & 1 deletion app/models/aliases/ems_network.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsNetwork = ::ManageIQ::Providers::NetworkManager
EmsNetwork = ManageIQ::Providers::NetworkManager
2 changes: 1 addition & 1 deletion app/models/aliases/ems_physical_infra.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsPhysicalInfra = ::ManageIQ::Providers::PhysicalInfraManager
EmsPhysicalInfra = ManageIQ::Providers::PhysicalInfraManager
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsRefresh::Refreshers::BaseRefresher = ManageIQ::Providers::BaseManager::Refresher
EmsRefresh::Refreshers::BaseRefresher = ManageIQ::Providers::BaseManager::Refresher
2 changes: 1 addition & 1 deletion app/models/aliases/ems_storage.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsStorage = ::ManageIQ::Providers::StorageManager
EmsStorage = ManageIQ::Providers::StorageManager
2 changes: 1 addition & 1 deletion app/models/aliases/miq_ems_metrics_collector_worker.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::MiqEmsMetricsCollectorWorker = ManageIQ::Providers::BaseManager::MetricsCollectorWorker
MiqEmsMetricsCollectorWorker = ManageIQ::Providers::BaseManager::MetricsCollectorWorker
2 changes: 1 addition & 1 deletion app/models/aliases/miq_ems_operations_worker.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::MiqEmsOperationsWorker = ManageIQ::Providers::BaseManager::OperationsWorker
MiqEmsOperationsWorker = ManageIQ::Providers::BaseManager::OperationsWorker
2 changes: 1 addition & 1 deletion app/models/aliases/miq_ems_refresh_worker.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::MiqEmsRefreshWorker = ManageIQ::Providers::BaseManager::RefreshWorker
MiqEmsRefreshWorker = ManageIQ::Providers::BaseManager::RefreshWorker
2 changes: 1 addition & 1 deletion app/models/aliases/miq_event_catcher.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::MiqEventCatcher = ManageIQ::Providers::BaseManager::EventCatcher
MiqEventCatcher = ManageIQ::Providers::BaseManager::EventCatcher
2 changes: 1 addition & 1 deletion app/models/aliases/miq_provision_cloud.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::MiqProvisionCloud = ::ManageIQ::Providers::CloudManager::Provision
MiqProvisionCloud = ManageIQ::Providers::CloudManager::Provision
2 changes: 1 addition & 1 deletion app/models/aliases/miq_provision_cloud_workflow.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::MiqProvisionCloudWorkflow = ::ManageIQ::Providers::CloudManager::ProvisionWorkflow
MiqProvisionCloudWorkflow = ManageIQ::Providers::CloudManager::ProvisionWorkflow
2 changes: 1 addition & 1 deletion app/models/aliases/miq_provision_infra_workflow.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::MiqProvisionInfraWorkflow = ::ManageIQ::Providers::InfraManager::ProvisionWorkflow
MiqProvisionInfraWorkflow = ManageIQ::Providers::InfraManager::ProvisionWorkflow
2 changes: 1 addition & 1 deletion app/models/aliases/template_cloud.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::TemplateCloud = ManageIQ::Providers::CloudManager::Template
TemplateCloud = ManageIQ::Providers::CloudManager::Template
2 changes: 1 addition & 1 deletion app/models/aliases/template_infra.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
require 'manageiq/providers/infra_manager/template'
::TemplateInfra = ManageIQ::Providers::InfraManager::Template
TemplateInfra = ManageIQ::Providers::InfraManager::Template
2 changes: 1 addition & 1 deletion app/models/aliases/vm_cloud.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::VmCloud = ManageIQ::Providers::CloudManager::Vm
VmCloud = ManageIQ::Providers::CloudManager::Vm
2 changes: 1 addition & 1 deletion app/models/aliases/vm_infra.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::VmInfra = ManageIQ::Providers::InfraManager::Vm
VmInfra = ManageIQ::Providers::InfraManager::Vm
2 changes: 1 addition & 1 deletion app/models/aliases/workers/ems_refresh_worker.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
::EmsRefreshWorker = ManageIQ::Providers::BaseManager::RefreshWorker::Runner
EmsRefreshWorker = ManageIQ::Providers::BaseManager::RefreshWorker::Runner
4 changes: 2 additions & 2 deletions app/models/aliases/workers/event_catcher.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
::EventCatcher = ManageIQ::Providers::BaseManager::EventCatcher::Runner
::EventCatcherHandledException = ::EventCatcher::EventCatcherHandledException
EventCatcher = ManageIQ::Providers::BaseManager::EventCatcher::Runner
EventCatcherHandledException = EventCatcher::EventCatcherHandledException
1 change: 1 addition & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def self.display_name(number = 1)

def self.human_attribute_name(attribute, options = {})
return super if options.delete(:ui) == true

"#{name}: #{super}"
end
end
58 changes: 28 additions & 30 deletions app/models/asset_tag_import.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
class AssetTagImport
include Vmdb::Logging

attr_accessor :errors
attr_accessor :stats
attr_accessor :errors, :stats

# The required fields list is not limited anymore, so pass nil.
REQUIRED_COLS = {VmOrTemplate => nil, Host => nil}
Expand All @@ -24,6 +23,7 @@ def self.upload(klass, fd)
klass = Object.const_get(klass.to_s)
raise _("%{name} not supported for upload!") % {:name => klass} unless REQUIRED_COLS.key?(klass)
raise _("%{name} not supported for upload!") % {:name => klass} unless MATCH_KEYS.key?(klass)

data, keys, tags = MiqBulkImport.upload(fd, REQUIRED_COLS[klass], MATCH_KEYS[klass].dup)

import = new(:data => data, :keys => keys, :tags => tags, :klass => klass)
Expand Down Expand Up @@ -69,13 +69,13 @@ def verify
end

@verified_data.each do |id, data|
if data.length > 1
obj = @klass.find_by(:id => id)
while data.length > 1
data.shift
_log.warn("#{@klass.name} #{obj.name}, Multiple lines for the same object, the last line is applied")
@errors.add(:singlevaluedassettag, "#{@klass.name}: #{obj.name}, Multiple lines for the same object, the last line is applied")
end
next unless data.length > 1

obj = @klass.find_by(:id => id)
while data.length > 1
data.shift
_log.warn("#{@klass.name} #{obj.name}, Multiple lines for the same object, the last line is applied")
@errors.add(:singlevaluedassettag, "#{@klass.name}: #{obj.name}, Multiple lines for the same object, the last line is applied")
end
end

Expand All @@ -87,31 +87,29 @@ def verify
def apply
@verified_data.each do |id, data|
obj = @klass.find_by(:id => id)
if obj
attrs = obj.miq_custom_attributes
new_attrs = []
data[0].each do |key, value|
# Add custom attribute here.
attr = attrs.detect { |ca| ca.name == key }
if attr.nil?
if value.blank?
_log.info("#{@klass.name}: #{obj.name}, Skipping tag <#{key}> due to blank value")
else
_log.info("#{@klass.name}: #{obj.name}, Adding tag <#{key}>, value <#{value}>")
new_attrs << {:name => key, :value => value, :source => 'EVM'}
end
next unless obj

attrs = obj.miq_custom_attributes
new_attrs = []
data[0].each do |key, value|
# Add custom attribute here.
attr = attrs.detect { |ca| ca.name == key }
if attr.nil?
if value.blank?
_log.info("#{@klass.name}: #{obj.name}, Skipping tag <#{key}> due to blank value")
else
if value.blank?
_log.info("#{@klass.name}: #{obj.name}, Deleting tag <#{key}> due to blank value")
attr.delete
else
_log.info("#{@klass.name}: #{obj.name}, Updating tag <#{key}>, value <#{value}>")
attr.update_attribute(:value, value)
end
_log.info("#{@klass.name}: #{obj.name}, Adding tag <#{key}>, value <#{value}>")
new_attrs << {:name => key, :value => value, :source => 'EVM'}
end
elsif value.blank?
_log.info("#{@klass.name}: #{obj.name}, Deleting tag <#{key}> due to blank value")
attr.delete
else
_log.info("#{@klass.name}: #{obj.name}, Updating tag <#{key}>, value <#{value}>")
attr.update_attribute(:value, value)
end
obj.custom_attributes.create(new_attrs)
end
obj.custom_attributes.create(new_attrs)
end
end

Expand Down