refactor: update ide ruby version, fix rubocop offenses

This commit is contained in:
Miguel Nogueira 2024-05-19 17:06:53 +01:00
parent 3b07ec4655
commit 5e0285028e
Signed by: miguel456
GPG Key ID: 43EF15DB0CC86DDD
3 changed files with 23 additions and 22 deletions

View File

@ -10,21 +10,21 @@
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/.bundle" />
</content>
<orderEntry type="jdk" jdkName="ruby-3.0.2-p107" jdkType="RUBY_SDK" />
<orderEntry type="jdk" jdkName="ruby-3.3.1-p55" 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" />
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, ruby-3.3.1-p55) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.5.9, ruby-3.3.1-p55) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="json (v2.7.2, ruby-3.3.1-p55) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="language_server-protocol (v3.17.0.3, ruby-3.3.1-p55) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.24.0, ruby-3.3.1-p55) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="parser (v3.3.1.0, ruby-3.3.1-p55) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="racc (v1.7.3, ruby-3.3.1-p55) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, ruby-3.3.1-p55) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.9.0, ruby-3.3.1-p55) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.6, ruby-3.3.1-p55) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rubocop (v1.63.4, ruby-3.3.1-p55) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.31.3, ruby-3.3.1-p55) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.13.0, ruby-3.3.1-p55) [gem]" level="application" />
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.5.0, ruby-3.3.1-p55) [gem]" level="application" />
</component>
</module>

View File

@ -0,0 +1,3 @@
<component name="ProjectDictionaryState">
<dictionary name="miguelnogueira" />
</component>

10
main.rb
View File

@ -42,9 +42,7 @@ end
def times_appeared_single(ips, ip_to_check)
counter = 0
ips.each do |ip|
if ip == ip_to_check
counter += 1
end
counter += 1 if ip == ip_to_check
end
counter
end
@ -69,7 +67,7 @@ client_errors = {}
user_agents = {}
all_ips = []
lines.each do | line |
lines.each do |line|
all_ips << get_line_ip(line)
end
@ -103,13 +101,13 @@ lines.each do |line|
end
top_user_agents = user_agents.sort_by { |ua, count| -count }.first(5)
top_user_agents = user_agents.sort_by { |_ua, count| -count }.first(5)
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)
top_client_errors = client_errors.sort_by { |_ip, count| -count }.first(5)
puts 'Top 5 IPs with most client errors (400-499):'
top_client_errors.each do |ip, count|
puts "#{ip}: #{count} errors"