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
Changes from 1 commit
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rubocop -a --only Style/Next
Fryguy committed Feb 29, 2024
commit 3c1ca73a7e49762bb59eab99484182f562d07e0b
52 changes: 25 additions & 27 deletions app/models/asset_tag_import.rb
Original file line number Diff line number Diff line change
@@ -69,13 +69,12 @@ 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

@@ -87,29 +86,28 @@ 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
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)
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
_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

19 changes: 9 additions & 10 deletions app/models/chargeback_rate_detail.rb
Original file line number Diff line number Diff line change
@@ -300,17 +300,16 @@ def self.default_rate_details_for(rate_type)

rate_details.push(detail_new)

if detail_new.chargeable_field.metric == 'derived_vm_allocated_disk_storage'
volume_types = CloudVolume.volume_types
volume_types.push('unclassified') if volume_types.present?
volume_types.each do |volume_type|
storage_detail_new = detail_new.dup
storage_detail_new.sub_metric = volume_type
detail[:tiers].sort_by { |tier| tier[:start] }.each do |tier|
storage_detail_new.chargeback_tiers << ChargebackTier.new(tier.slice(*ChargebackTier::FORM_ATTRIBUTES))
end
rate_details.push(storage_detail_new)
next unless detail_new.chargeable_field.metric == 'derived_vm_allocated_disk_storage'
volume_types = CloudVolume.volume_types
volume_types.push('unclassified') if volume_types.present?
volume_types.each do |volume_type|
storage_detail_new = detail_new.dup
storage_detail_new.sub_metric = volume_type
detail[:tiers].sort_by { |tier| tier[:start] }.each do |tier|
storage_detail_new.chargeback_tiers << ChargebackTier.new(tier.slice(*ChargebackTier::FORM_ATTRIBUTES))
end
rate_details.push(storage_detail_new)
end
end
end
44 changes: 20 additions & 24 deletions app/models/classification_import.rb
Original file line number Diff line number Diff line change
@@ -54,11 +54,10 @@ def verify
@verified_data[vms[0].id][line["category"]] ||= []
entry = nil
cat.entries.each do |e|
if e.description == line["entry"]
@verified_data[vms[0].id][line["category"]].push(line["entry"])
entry = e
break
end
next unless e.description == line["entry"]
@verified_data[vms[0].id][line["category"]].push(line["entry"])
entry = e
break
end
if entry.nil?
bad += 1
@@ -73,13 +72,12 @@ def verify
@verified_data.each do |id, data|
data.each do |category, entries|
cat = Classification.find_by(:description => category)
if cat.single_value && entries.length > 1
vm = VmOrTemplate.find_by(:id => id)
while entries.length > 1
e = entries.shift
_log.warn("Vm: #{vm.name}, Location: #{vm.location}, Category: #{category}: Multiple values given for single-valued category, value #{e} will be ignored")
@errors.add(:singlevaluedcategory, "Vm #{vm.name}, Location: #{vm.location}, Category: #{category}: Multiple values given for single-valued category, value #{e} will be ignored")
end
next unless cat.single_value && entries.length > 1
vm = VmOrTemplate.find_by(:id => id)
while entries.length > 1
e = entries.shift
_log.warn("Vm: #{vm.name}, Location: #{vm.location}, Category: #{category}: Multiple values given for single-valued category, value #{e} will be ignored")
@errors.add(:singlevaluedcategory, "Vm #{vm.name}, Location: #{vm.location}, Category: #{category}: Multiple values given for single-valued category, value #{e} will be ignored")
end
end
end
@@ -91,19 +89,17 @@ def verify
def apply
@verified_data.each do |id, data|
vm = VmOrTemplate.find_by(:id => id)
if vm
data.each do |category, entries|
cat = Classification.find_by(:description => category)
next unless cat
next unless vm
data.each do |category, entries|
cat = Classification.find_by(:description => category)
next unless cat

entries.each do |ent|
cat.entries.each do |e|
if e.description == ent
_log.info("Vm: #{vm.name}, Location: #{vm.location}, Category: #{cat.description}: Applying entry #{ent}")
e.assign_entry_to(vm)
break
end
end
entries.each do |ent|
cat.entries.each do |e|
next unless e.description == ent
_log.info("Vm: #{vm.name}, Location: #{vm.location}, Category: #{cat.description}: Applying entry #{ent}")
e.assign_entry_to(vm)
break
end
end
end
21 changes: 10 additions & 11 deletions app/models/compliance.rb
Original file line number Diff line number Diff line change
@@ -15,17 +15,16 @@ def self.check_compliance_queue(targets, inputs = {})

def self.scan_and_check_compliance_queue(targets, inputs = {})
Array.wrap(targets).each do |target|
if target.kind_of?(Host)
# Queue this with the vc-refresher taskid, so that any concurrent ems_refreshes don't clash with this one.
MiqQueue.put(
:class_name => name,
:method_name => 'scan_and_check_compliance',
:args => [[target.class.name, target.id], inputs],
:task_id => 'vc-refresher',
:role => "ems_inventory",
:zone => target.ext_management_system.try(:my_zone)
)
end
next unless target.kind_of?(Host)
# Queue this with the vc-refresher taskid, so that any concurrent ems_refreshes don't clash with this one.
MiqQueue.put(
:class_name => name,
:method_name => 'scan_and_check_compliance',
:args => [[target.class.name, target.id], inputs],
:task_id => 'vc-refresher',
:role => "ems_inventory",
:zone => target.ext_management_system.try(:my_zone)
)
end
end

11 changes: 5 additions & 6 deletions app/models/ems_refresh/save_inventory.rb
Original file line number Diff line number Diff line change
@@ -222,12 +222,11 @@ def save_guest_devices_inventory(hardware, hashes)
hardware.save! if hardware.id.nil?
h[:network][:hardware_id] = hardware.id
end
if h[:child_devices]
# Save the hardware to force an id if not found
hardware.save! if hardware.id.nil?
h[:child_devices].each do |child_device|
child_device[:hardware_id] = hardware.id
end
next unless h[:child_devices]
# Save the hardware to force an id if not found
hardware.save! if hardware.id.nil?
h[:child_devices].each do |child_device|
child_device[:hardware_id] = hardware.id
end
end

9 changes: 4 additions & 5 deletions app/models/host.rb
Original file line number Diff line number Diff line change
@@ -847,12 +847,11 @@ def refresh_ssh_config(ssu)
self.ssh_permit_root_login = 'yes' if permit_list
permit_list.each_line do |line|
la = line.split(' ')
if la.length == 2
next if la.first[0, 1] == '#'
next unless la.length == 2
next if la.first[0, 1] == '#'

self.ssh_permit_root_login = la.last.to_s.downcase
break
end
self.ssh_permit_root_login = la.last.to_s.downcase
break
end
rescue
# _log.log_backtrace($!)
15 changes: 7 additions & 8 deletions app/models/metric/long_term_averages.rb
Original file line number Diff line number Diff line change
@@ -17,14 +17,13 @@ module Metric::LongTermAverages
:column => col,
:type => type
}
unless AVG_COLS_TO_OVERHEAD_TYPE[col].nil?
AVG_METHODS_WITHOUT_OVERHEAD_INFO[:"#{meth}_without_overhead"] = {
:column => col,
:type => type,
:base_meth => meth,
:overhead_type => AVG_COLS_TO_OVERHEAD_TYPE[col]
}
end
next if AVG_COLS_TO_OVERHEAD_TYPE[col].nil?
AVG_METHODS_WITHOUT_OVERHEAD_INFO[:"#{meth}_without_overhead"] = {
:column => col,
:type => type,
:base_meth => meth,
:overhead_type => AVG_COLS_TO_OVERHEAD_TYPE[col]
}
end

AVG_METHODS = AVG_METHODS_INFO.keys
9 changes: 4 additions & 5 deletions app/models/miq_action.rb
Original file line number Diff line number Diff line change
@@ -79,12 +79,11 @@ def validate
self.options ||= {}
self.options[:to] ||= ""
[:from, :to].each do |k|
if self.options && self.options[k]
next if k == :from && self.options[k].blank? # allow blank from addres, we use the default.
next unless self.options && self.options[k]
next if k == :from && self.options[k].blank? # allow blank from addres, we use the default.

match = self.options[k] =~ /^\A([\w\.\-\+]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z$/i
errors.add(k, "must be a valid email address") unless match
end
match = self.options[k] =~ /^\A([\w\.\-\+]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z$/i
errors.add(k, "must be a valid email address") unless match
end
when "tag"
errors.add("tag", "no tags provided") unless self.options && self.options[:tags]
20 changes: 9 additions & 11 deletions app/models/miq_alert.rb
Original file line number Diff line number Diff line change
@@ -799,17 +799,15 @@ def self.seed
alist.each do |alert_hash|
guid = alert_hash["guid"] || alert_hash[:guid]
rec = find_by(:guid => guid)
if rec.nil?
alert_hash[:read_only] = true
alert = create(alert_hash)
_log.info("Added sample Alert: #{alert.description}")
if action
alert.options ||= {}
alert.options[:notifications] ||= {}
alert.options[:notifications][action.action_type.to_sym] = action.options
alert.save
end
end
next unless rec.nil?
alert_hash[:read_only] = true
alert = create(alert_hash)
_log.info("Added sample Alert: #{alert.description}")
next unless action
alert.options ||= {}
alert.options[:notifications] ||= {}
alert.options[:notifications][action.action_type.to_sym] = action.options
alert.save
end
end
end
9 changes: 4 additions & 5 deletions app/models/miq_group.rb
Original file line number Diff line number Diff line change
@@ -129,11 +129,10 @@ def self.seed
group.group_type = SYSTEM_GROUP
group.tenant = root_tenant

if group.changed?
mode = group.new_record? ? "Created" : "Updated"
group.save!
_log.info("#{mode} Group: #{group.description} with Role: #{user_role.name}")
end
next unless group.changed?
mode = group.new_record? ? "Created" : "Updated"
group.save!
_log.info("#{mode} Group: #{group.description} with Role: #{user_role.name}")
end

# find any default tenant groups that do not have a role
9 changes: 4 additions & 5 deletions app/models/miq_policy/import_export.rb
Original file line number Diff line number Diff line change
@@ -44,11 +44,10 @@ def import_from_hash(policy, options = {})
event_status[:children] ||= []
e2a[ekey].each do |arr|
akey, opts = arr
unless akey.nil?
action, s = actionsHash[akey]
actions.push([action, opts])
event_status[:children].push(s)
end
next if akey.nil?
action, s = actionsHash[akey]
actions.push([action, opts])
event_status[:children].push(s)
end

events.push([event, actions])
17 changes: 8 additions & 9 deletions app/models/miq_report/generator.rb
Original file line number Diff line number Diff line change
@@ -541,17 +541,16 @@ def build_correlate_tag_cols
arr = self.cols.each_with_object([]) do |c, a|
self.extras[:group_by_tag_cols].each do |tc|
tag = tc[(c.length + 1)..-1]
if tc.starts_with?(c)
unless tags2desc.key?(tag)
if tag == "_none_"
tags2desc[tag] = "[None]"
else
entry = Classification.lookup_by_name([performance[:group_by_category], tag].join("/"))
tags2desc[tag] = entry.nil? ? tag.titleize : entry.description
end
next unless tc.starts_with?(c)
unless tags2desc.key?(tag)
if tag == "_none_"
tags2desc[tag] = "[None]"
else
entry = Classification.lookup_by_name([performance[:group_by_category], tag].join("/"))
tags2desc[tag] = entry.nil? ? tag.titleize : entry.description
end
a << [tc, tags2desc[tag]]
end
a << [tc, tags2desc[tag]]
end
end
arr.sort_by! { |a| a[1] }
31 changes: 15 additions & 16 deletions app/models/miq_report/generator/html.rb
Original file line number Diff line number Diff line change
@@ -156,24 +156,23 @@ def build_group_html_rows(group, col_count, label = nil, group_text = nil)

if extras && extras[:grouping] && extras[:grouping][group] # See if group key exists
MiqReport::GROUPINGS.each do |calc| # Add an output row for each group calculation
if extras[:grouping][group].key?(calc.first) # Only add a row if there are calcs of this type for this group value
grp_output = ""
grp_output << "<tr>"
grp_output << "<td#{in_a_widget ? "" : " class='group'"} style='text-align:right'>#{_(calc.last)}:</td>"
col_order.each_with_index do |c, c_idx| # Go through the columns
next if c_idx == 0 # Skip first column

grp_output << "<td#{in_a_widget ? "" : " class='group'"} style='text-align:right'>"
if extras[:grouping][group].key?(calc.first)
grp_output << CGI.escapeHTML(
c.split("__").first % [extras[:grouping][group][calc.first][c], {:format => self.col_formats[c_idx] ? self.col_formats[c_idx] : :_default_}]
)
end
grp_output << "</td>"
next unless extras[:grouping][group].key?(calc.first) # Only add a row if there are calcs of this type for this group value
grp_output = ""
grp_output << "<tr>"
grp_output << "<td#{in_a_widget ? "" : " class='group'"} style='text-align:right'>#{_(calc.last)}:</td>"
col_order.each_with_index do |c, c_idx| # Go through the columns
next if c_idx == 0 # Skip first column

grp_output << "<td#{in_a_widget ? "" : " class='group'"} style='text-align:right'>"
if extras[:grouping][group].key?(calc.first)
grp_output << CGI.escapeHTML(
c.split("__").first % [extras[:grouping][group][calc.first][c], {:format => self.col_formats[c_idx] ? self.col_formats[c_idx] : :_default_}]
)
end
grp_output << "</tr>"
html_rows << grp_output
grp_output << "</td>"
end
grp_output << "</tr>"
html_rows << grp_output
end
end
html_rows << "<tr><td class='group_spacer' colspan='#{col_count}'>&nbsp;</td></tr>" unless group == :_total_
Loading