Page MenuHomeDevCentral

Follow the community Ruby Style Guide
Open, NormalPublic

Description

The Ruby community maintain a style guide.

RuboCop is a static analysis tool for Ruby source code, which could automatically find violation for this style guide.

It's triggered by Arcanist at diff time or manually through arc lint --everything.

We need to upgrade code to pass linter checks:

1>>> Lint for tommy.rb:
2
3
4 Warning (Style/FrozenStringLiteralComment) RuboCop
5 Style/FrozenStringLiteralComment: Missing magic comment `#
6 frozen_string_literal: true`.
7
8 >>> 1 # -------------------------------------------------------------
9 ^
10 2 # Tommy - Visualisation dashboard for Jenkins
11 3 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
12 4 # Author: Arfon Smitn (Zooniverse)
13
14 Warning (Metrics/AbcSize) RuboCop
15 Metrics/AbcSize: Assignment Branch Condition size for parse_project is
16 too high. [25.81/15]
17
18 52 ##
19 53 # Parses a job element of the Jenkins API.
20 54 # Returns a Project instance.
21 >>> 55 def self.parse_project(data)
22 ^
23 56 project = Project.new(
24 57 name: data['displayName'].tr('-', ' '),
25 58 last_build_number: data['builds'].first['number'],
26
27 Warning (Metrics/MethodLength) RuboCop
28 Metrics/MethodLength: Method has too many lines. [24/10]
29
30 52 ##
31 53 # Parses a job element of the Jenkins API.
32 54 # Returns a Project instance.
33 >>> 55 def self.parse_project(data)
34 ^
35 56 project = Project.new(
36 57 name: data['displayName'].tr('-', ' '),
37 58 last_build_number: data['builds'].first['number'],
38
39 Warning (Layout/EmptyLineAfterGuardClause) RuboCop
40 Layout/EmptyLineAfterGuardClause: Add empty line after guard clause.
41
42 74 'lastFailedBuild' => 'last_failed_url='
43 75 }
44 76 urls.each do |api_property, local_property|
45 >>> 77 next if data[api_property].blank?
46 ^
47 78 project.send(local_property, data[api_property]['url'])
48 79 end
49 80

See also P204 for the output from rubocop tommy.b (the same, more compact).

Event Timeline

dereckson updated the task description. (Show Details)
dereckson moved this task from Backlog to Dev on the good-first-issue board.

I've updated P203 and P204 with current rubocop output, to take in consideration previous commits.