Skip to content

Commit

Permalink
[api][webui] Update rubocop todo file and fix a few offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
bgeuken committed Aug 25, 2016
1 parent b782e02 commit b76e98e
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 52 deletions.
101 changes: 68 additions & 33 deletions src/api/.rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-07-21 14:07:00 +0000 using RuboCop version 0.41.2.
# on 2016-08-10 16:07:30 +0000 using RuboCop version 0.42.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -19,7 +19,7 @@ Lint/Eval:
Exclude:
- 'config/environments/development.rb'

# Offense count: 24
# Offense count: 25
Lint/HandleExceptions:
Enabled: false

Expand Down Expand Up @@ -87,15 +87,14 @@ Lint/RescueException:
- 'config/environment.rb'
- 'lib/tasks/extract.rake'

# Offense count: 6
# Offense count: 5
Lint/ShadowedException:
Exclude:
- 'app/controllers/webui/package_controller.rb'
- 'app/models/bs_request_action.rb'
- 'app/models/issue_tracker.rb'
- 'app/controllers/webui/project_controller.rb'
- 'app/controllers/webui/request_controller.rb'
- 'lib/activexml/transport.rb'
- 'lib/opensuse/backend.rb'
- 'test/functional/webui/spider_test.rb'

# Offense count: 9
Lint/UnderscorePrefixedVariableName:
Expand All @@ -115,29 +114,30 @@ Lint/UnusedBlockArgument:
- 'lib/activexml/transport.rb'

# Offense count: 2
# Configuration parameters: ContextCreatingMethods.
Lint/UselessAccessModifier:
Exclude:
- 'app/models/user.rb'
- 'test/activexml_matcher.rb'

# Offense count: 48
# Offense count: 49
Lint/UselessAssignment:
Enabled: false

# Offense count: 1051
# Offense count: 1050
Metrics/AbcSize:
Max: 284

# Offense count: 28
Metrics/BlockNesting:
Max: 6

# Offense count: 110
# Offense count: 111
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 1927

# Offense count: 255
# Offense count: 254
Metrics/CyclomaticComplexity:
Max: 67

Expand Down Expand Up @@ -201,7 +201,7 @@ Performance/StringReplacement:
- 'lib/xpath_engine.rb'
- 'test/functional/kgraft_maintenance_test.rb'

# Offense count: 67
# Offense count: 69
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, Include.
# SupportedStyles: action, filter
Expand Down Expand Up @@ -272,10 +272,11 @@ Rails/Output:
- 'lib/opensuse/backend.rb'
- 'lib/workers/import_requests.rb'

# Offense count: 29
# Offense count: 31
Rails/OutputSafety:
Exclude:
- 'app/helpers/comment_helper.rb'
- 'app/helpers/webui/buildstatus_helper.rb'
- 'app/helpers/webui/package_helper.rb'
- 'app/helpers/webui/project_helper.rb'
- 'app/helpers/webui/webui_helper.rb'
Expand Down Expand Up @@ -365,7 +366,7 @@ Style/AsciiComments:
Style/BlockDelimiters:
Enabled: false

# Offense count: 156
# Offense count: 186
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: braces, no_braces, context_dependent
Expand All @@ -392,7 +393,7 @@ Style/CaseIndentation:
- 'lib/opensuse/validator.rb'
- 'test/unit/tagcloud_test.rb'

# Offense count: 112
# Offense count: 113
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Expand Down Expand Up @@ -439,7 +440,7 @@ Style/ColonMethodCall:
- 'config/initializers/activexml.rb'
- 'config/unicorn/development.rb'

# Offense count: 20
# Offense count: 19
# Cop supports --auto-correct.
# Configuration parameters: Keywords.
# Keywords: TODO, FIXME, OPTIMIZE, HACK, REVIEW
Expand All @@ -450,7 +451,6 @@ Style/CommentAnnotation:
- 'app/controllers/tag_controller.rb'
- 'app/controllers/webui/main_controller.rb'
- 'app/controllers/webui/package_controller.rb'
- 'app/controllers/webui/project_controller.rb'
- 'app/helpers/branch_package.rb'
- 'app/models/bs_request_action.rb'
- 'app/models/bs_request_action_group.rb'
Expand All @@ -460,7 +460,7 @@ Style/CommentAnnotation:
- 'test/functional/build_controller_test.rb'
- 'test/functional/request_controller_test.rb'

# Offense count: 78
# Offense count: 76
# Cop supports --auto-correct.
Style/CommentIndentation:
Enabled: false
Expand All @@ -481,7 +481,7 @@ Style/ConstantName:
- 'app/models/event/request.rb'
- 'test/unit/issue_test.rb'

# Offense count: 511
# Offense count: 512
Style/Documentation:
Enabled: false

Expand All @@ -498,6 +498,7 @@ Style/DoubleNegation:
- 'app/models/project.rb'

# Offense count: 2
# Cop supports --auto-correct.
Style/EachWithObject:
Exclude:
- 'app/models/project.rb'
Expand All @@ -507,7 +508,7 @@ Style/EachWithObject:
Style/EmptyLiteral:
Enabled: false

# Offense count: 85
# Offense count: 84
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
Style/ExtraSpacing:
Expand Down Expand Up @@ -567,7 +568,7 @@ Style/GlobalVars:
Style/GuardClause:
Enabled: false

# Offense count: 10618
# Offense count: 10607
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
# SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets
Expand All @@ -587,7 +588,7 @@ Style/IdenticalConditionalBranches:
Style/IfInsideElse:
Enabled: false

# Offense count: 193
# Offense count: 191
# Cop supports --auto-correct.
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Expand All @@ -613,7 +614,7 @@ Style/IndentAssignment:
- 'app/helpers/webui/webui_helper.rb'
- 'app/models/bs_request_permission_check.rb'

# Offense count: 38
# Offense count: 42
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_braces
Expand Down Expand Up @@ -654,7 +655,7 @@ Style/InfiniteLoop:
Style/LineEndConcatenation:
Enabled: false

# Offense count: 77
# Offense count: 79
# Cop supports --auto-correct.
Style/MethodCallParentheses:
Enabled: false
Expand All @@ -666,6 +667,12 @@ Style/MethodCallParentheses:
Style/MethodDefParentheses:
Enabled: false

# Offense count: 2
Style/MethodMissing:
Exclude:
- 'app/models/configuration.rb'
- 'lib/opensuse/permission.rb'

# Offense count: 29
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: snake_case, camelCase
Expand Down Expand Up @@ -730,7 +737,7 @@ Style/MultilineMethodCallIndentation:
Style/MultilineOperationIndentation:
Enabled: false

# Offense count: 36
# Offense count: 37
# Cop supports --auto-correct.
Style/MutableConstant:
Enabled: false
Expand Down Expand Up @@ -865,7 +872,7 @@ Style/Proc:
- 'app/models/owner.rb'
- 'app/models/user.rb'

# Offense count: 261
# Offense count: 262
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: compact, exploded
Expand Down Expand Up @@ -901,10 +908,11 @@ Style/RedundantException:
- 'lib/opensuse/permission.rb'
- 'lib/wizard.rb'

# Offense count: 9
# Offense count: 10
# Cop supports --auto-correct.
Style/RedundantParentheses:
Exclude:
- 'app/models/owner.rb'
- 'app/models/project.rb'
- 'app/models/project_log_entry.rb'
- 'app/models/tagcloud.rb'
Expand Down Expand Up @@ -1010,7 +1018,7 @@ Style/SpaceAroundKeyword:
Exclude:
- 'spec/models/user_spec.rb'

# Offense count: 913
# Offense count: 911
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Style/SpaceAroundOperators:
Expand All @@ -1023,7 +1031,7 @@ Style/SpaceAroundOperators:
Style/SpaceBeforeBlockBraces:
Enabled: false

# Offense count: 114
# Offense count: 115
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
# SupportedStyles: space, no_space
Expand All @@ -1049,7 +1057,7 @@ Style/SpaceInsideBrackets:
- 'test/functional/channel_maintenance_test.rb'
- 'test/functional/read_permission_test.rb'

# Offense count: 1884
# Offense count: 1901
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
# SupportedStyles: space, no_space, compact
Expand Down Expand Up @@ -1093,7 +1101,7 @@ Style/SpecialGlobalVars:
- 'lib/memory_dumper.rb'
- 'test/unit/schema_test.rb'

# Offense count: 9097
# Offense count: 9188
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Expand Down Expand Up @@ -1136,6 +1144,18 @@ Style/Tab:
- 'lib/memory_debugger.rb'
- 'lib/tasks/sprites.rake'

# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowSafeAssignment.
# SupportedStyles: require_parentheses, require_no_parentheses
Style/TernaryParentheses:
Exclude:
- 'app/controllers/public_controller.rb'
- 'app/helpers/public_helper.rb'
- 'app/models/backend_file.rb'
- 'app/models/project_log_entry.rb'
- 'app/models/unregistered_user.rb'

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
Expand All @@ -1146,10 +1166,25 @@ Style/TrivialAccessors:
- 'lib/activexml/node.rb'
- 'test/test_helper.rb'

# Offense count: 29
# Offense count: 28
# Cop supports --auto-correct.
Style/UnneededInterpolation:
Enabled: false
Exclude:
- 'app/controllers/application_controller.rb'
- 'app/controllers/tag_controller.rb'
- 'app/controllers/webui/package_controller.rb'
- 'app/controllers/webui/search_controller.rb'
- 'app/helpers/branch_package.rb'
- 'app/helpers/validation_helper.rb'
- 'app/helpers/webui/patchinfo_helper.rb'
- 'app/mixins/build_log_support.rb'
- 'app/models/user_ldap_strategy.rb'
- 'lib/opensuse/backend.rb'
- 'spec/features/webui/projects_spec.rb'
- 'test/functional/branch_publish_flag_test.rb'
- 'test/functional/read_permission_test.rb'
- 'test/functional/release_management_test.rb'
- 'test/functional/request_controller_test.rb'

# Offense count: 136
# Configuration parameters: EnforcedStyle, SupportedStyles.
Expand All @@ -1164,7 +1199,7 @@ Style/VariableName:
Style/WordArray:
Enabled: false

# Offense count: 33
# Offense count: 28
# Cop supports --auto-correct.
Style/ZeroLengthPredicate:
Enabled: false
2 changes: 1 addition & 1 deletion src/api/app/controllers/search_controller.rb
Expand Up @@ -122,7 +122,7 @@ def filter_items(items)
nitems << item
if @limit
@limit -= 1
break if @limit == 0
break if @limit.zero?
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/statistics_controller.rb
Expand Up @@ -182,8 +182,8 @@ def global_counters
end

def get_limit
return @limit = nil if not params[:limit].nil? and params[:limit].to_i == 0
@limit = 10 if (@limit = params[:limit].to_i) == 0
return @limit = nil if not params[:limit].nil? and params[:limit].to_i.zero?
@limit = 10 if (@limit = params[:limit].to_i).zero?
end

def active_request_creators
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/monitor_controller.rb
Expand Up @@ -128,7 +128,7 @@ def self.addarrays(arr1, arr2)
time2 ||= 0
ret << [(time1+time2)/2, value1 + value2]
end if arr1
ret << 0 if ret.length == 0
ret << 0 if ret.length.zero?
return ret
end

Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/webui/package_controller.rb
Expand Up @@ -869,12 +869,12 @@ def update_build_log
@finished = false
@maxsize = 1024 * 64

set_initial_offset if @offset == 0
set_initial_offset if @offset.zero?

begin
@log_chunk = get_log_chunk( @project, @package, @repo, @arch, @offset, @offset + @maxsize)

if @log_chunk.length == 0
if @log_chunk.length.zero?
@finished = true
else
@offset += ActiveXML::backend.last_body_length
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/helpers/webui/project_helper.rb
Expand Up @@ -93,7 +93,7 @@ def patchinfo_category_color(category)
end

def incident_issue_color(patchinfo_issues, package_issues)
return 'red' if package_issues == 0
return 'red' if package_issues.zero?
if patchinfo_issues == package_issues
return 'green'
elsif patchinfo_issues < package_issues
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/models/channel.rb
Expand Up @@ -148,7 +148,7 @@ def branch_channel_package_into_project(project, comment = nil)

def is_active?
# no targets defined, the project has some
return true if self.channel_targets.size == 0
return true if self.channel_targets.size.zero?

self.channel_targets.where(disabled: false).size > 0
end
Expand Down

0 comments on commit b76e98e

Please sign in to comment.