Commit af76f6af authored by Pablo Carranza's avatar Pablo Carranza

Add initial rubocop

parent 6d9ac9aa
# Commonly used screens these days easily fit more than 80 characters.
Metrics/LineLength:
Max: 120
# Just use double quotes please
Style/StringLiterals:
EnforcedStyle: double_quotes
# Jim Weirich block style
Style/BlockDelimiters:
EnforcedStyle: semantic
Style/SignalException:
EnforcedStyle: semantic
Style/RaiseArgs:
EnforcedStyle: compact
......@@ -2,4 +2,5 @@ source "https://rubygems.org"
group :test do
gem "rspec", "~>3.5"
gem "rubocop", "~>0.42"
end
GEM
remote: https://rubygems.org/
specs:
ast (2.3.0)
diff-lcs (1.2.5)
parser (2.3.1.2)
ast (~> 2.2)
powerpack (0.1.1)
rainbow (2.1.0)
rspec (3.5.0)
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
......@@ -15,12 +20,21 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
rspec-support (3.5.0)
rubocop (0.42.0)
parser (>= 2.3.1.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
unicode-display_width (1.1.0)
PLATFORMS
ruby
DEPENDENCIES
rspec (~> 3.5)
rubocop (~> 0.42)
BUNDLED WITH
1.12.5
......@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.files = `git ls-files -z`.split("\x0")
s.executables = ['gitlab-mon']
s.executables = ["gitlab-mon"]
s.test_files = s.files.grep(%r{^(spec)/})
s.require_paths = ["lib"]
......
module GitLab
module Monitor
module CLI
EXECUTABLE_NAME = "gitlab-mon"
EXECUTABLE_NAME = "gitlab-mon".freeze
def self.for(name)
commands.fetch(name, NullRunner)
......@@ -14,13 +14,13 @@ module GitLab
end
def run
fail InvalidCLICommand.new "Usage: #{EXECUTABLE_NAME} <command> [options] [arguments...]\n\n"\
"Available commands are: #{GitLab::Monitor::CLI.commands.keys.join(', ')}"
fail InvalidCLICommand.new("Usage: #{EXECUTABLE_NAME} <command> [options] [arguments...]\n\n"\
"Available commands are: #{GitLab::Monitor::CLI.commands.keys.join(', ')}")
end
end
class GIT
COMMAND_NAME="git"
COMMAND_NAME = "git".freeze
attr_reader :source, :target, :labels
......
......@@ -4,7 +4,7 @@ module GitLab
module Monitor
class Git
def initialize(repo)
fail "Repository #{repo} does not exists" unless Dir.exists? repo
fail "Repository #{repo} does not exists" unless Dir.exist? repo
@repo = repo
@tracker = TimeTracker.new
end
......@@ -33,7 +33,7 @@ module GitLab
CommandResult = Struct.new(:stdout, :status) do
def failed?
status != 0
status.nonzero?
end
def status
......
......@@ -13,7 +13,7 @@ module GitLab
def to_s
buffer = StringIO.new
@metrics.each { |name, metrics|
buffer.write("#{name}")
buffer.write(name.to_s)
labels = (metrics[:labels] || {}).map { |label, value| "#{label}=\"#{value}\"" }.join(",")
buffer.write("{#{labels}}") unless labels.empty?
buffer.write(" #{metrics[:value]} #{metrics[:timestamp]}\n")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment