refactor: fix rubocop offenses

This commit is contained in:
Miguel Nogueira 2024-05-19 03:44:18 +01:00
parent d84dd54893
commit a1f574e2da
Signed by: miguel456
GPG Key ID: 43EF15DB0CC86DDD
2 changed files with 17 additions and 4 deletions

View File

@ -12,6 +12,19 @@
</content>
<orderEntry type="jdk" jdkName="ruby-3.0.2-p107" jdkType="RUBY_SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, ruby-3.0.2-p107) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.5.9, ruby-3.0.2-p107) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="json (v2.7.2, ruby-3.0.2-p107) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="language_server-protocol (v3.17.0.3, ruby-3.0.2-p107) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.24.0, ruby-3.0.2-p107) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="parser (v3.3.1.0, ruby-3.0.2-p107) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="racc (v1.7.3, ruby-3.0.2-p107) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, ruby-3.0.2-p107) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.9.0, ruby-3.0.2-p107) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.6, ruby-3.0.2-p107) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rubocop (v1.63.4, ruby-3.0.2-p107) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.31.3, ruby-3.0.2-p107) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.13.0, ruby-3.0.2-p107) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.5.0, ruby-3.0.2-p107) [gem]" level="application" />
</component>
</module>

View File

@ -4,7 +4,7 @@ require 'date'
require_relative 'utils/http_codes'
require_relative 'utils/date_for_humans'
logfile = File.open("teambuilder.pt.log")
logfile = File.open('teambuilder.pt.log')
data = logfile.read
lines = data.split("\n")
@ -21,7 +21,7 @@ def get_line_date(line)
match = line.match(pattern)[0] if line.match(pattern)
# [12/Apr/2023:13:56:41 +0100] -> 12/Apr/2023:13:56:41 +0100
Date.parse(match.gsub("[", "").gsub("]", ""))
Date.parse(match.gsub('[', '').gsub(']', ''))
end
# Gets the HTTP status code of the given log line
@ -104,13 +104,13 @@ lines.each do |line|
end
top_user_agents = user_agents.sort_by { |ua, count| -count }.first(5)
puts "Top 5 User-Agents contacting the site:"
puts 'Top 5 User-Agents contacting the site:'
top_user_agents.each do |ua, count|
puts "#{ua}: #{count} visits"
end
top_client_errors = client_errors.sort_by { |ip, count| -count }.first(5)
puts "Top 5 IPs with most client errors (400-499):"
puts 'Top 5 IPs with most client errors (400-499):'
top_client_errors.each do |ip, count|
puts "#{ip}: #{count} errors"
end