trainee-rep's People
trainee-rep's Issues
letter counter: remove redundant nixfile
Poker homework: fix broken specs
trainee-rep/homework$ rspec
F
Failures:
1) Poker when finder
Failure/Error: expect { poker.finder("straight") }.to.contain("Iteration count")
ArgumentError:
wrong number of arguments (given 0, expected 1..2)
# ./spec/poker_spec.rb:7:in `block (3 levels) in <top (required)>'
Finished in 0.00081 seconds (files took 0.2479 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./spec/poker_spec.rb:6 # Poker when finder
Please fix RuboCop offenses for letter counter
$ rubocop letter_counter.rb
Inspecting 1 file
C
Offenses:
letter_counter.rb:1:1: C: Missing top-level class documentation comment.
class LetterCounter
^^^^^
letter_counter.rb:2:21: C: Use def with parentheses when there are parameters.
def count_letters string
^^^^^^
letter_counter.rb:4:9: C: Operator = should be surrounded by a single space.
res = string.gsub(/[a-zA-Z]/)
^
letter_counter.rb:4:10: C: Unnecessary spacing detected.
res = string.gsub(/[a-zA-Z]/)
^
letter_counter.rb:6:7: C: Use the return of the conditional for variable assignment and comparison.
if out.key?(item) ...
^^^^^^^^^^^^^^^^^
1 file inspected, 5 offenses detected
Beauty strings: wrong result
Input: BBC
Expected result: 77
Actual result: 76
RSS audio: resolve RuboCop offenses
domenic99/trainee-rep/rss_audio$ rubocop
Inspecting 40 files
C.C.CCCCCC....C..C.C...C.....WCCCC.CCC..
Offenses:
Rakefile:2:81: C: Line is too long. [90/80]
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
^^^^^^^^^^
Gemfile:3:1: C: Extra blank line detected.
Gemfile:34:81: C: Line is too long. [83/80]
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
^^^
Gemfile:39:81: C: Line is too long. [93/80]
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
^^^^^^^^^^^^^
Gemfile:41:3: C: Gem listen should appear before web-console in their gem group.
gem 'listen', '~> 3.0.5'
^^^^^^^^^^^^^^^^^^^^^^^^
Gemfile:42:81: C: Line is too long. [130/80]
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test/test_helper.rb:5:7: C: Use nested module/class definitions instead of compact style.
class ActiveSupport::TestCase
^^^^^^^^^^^^^^^^^^^^^^^
test/test_helper.rb:6:81: C: Line is too long. [82/80]
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
^^
config/environments/production.rb:2:81: C: Line is too long. [85/80]
# Settings specified here will take precedence over those in config/application.rb.
^^^^^
config/environments/production.rb:28:81: C: Line is too long. [102/80]
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
^^^^^^^^^^^^^^^^^^^^^^
config/environments/production.rb:40:81: C: Line is too long. [96/80]
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
^^^^^^^^^^^^^^^^
config/environments/production.rb:42:81: C: Line is too long. [96/80]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
^^^^^^^^^^^^^^^^
config/environments/production.rb:50:22: C: Space inside square brackets detected.
config.log_tags = [ :request_id ]
^
config/environments/production.rb:50:34: C: Space inside square brackets detected.
config.log_tags = [ :request_id ]
^
config/environments/production.rb:55:81: C: Line is too long. [83/80]
# Use a real queuing backend for Active Job (and separate queues per environment)
^^^
config/environments/production.rb:61:81: C: Line is too long. [100/80]
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
^^^^^^^^^^^^^^^^^^^^
config/environments/production.rb:76:81: C: Line is too long. [83/80]
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
^^^
config/environments/production.rb:78:10: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
if ENV["RAILS_LOG_TO_STDOUT"].present?
^^^^^^^^^^^^^^^^^^^^^
config/environments/development.rb:2:81: C: Line is too long. [85/80]
# Settings specified here will take precedence over those in config/application.rb.
^^^^^
config/environments/test.rb:2:81: C: Line is too long. [85/80]
# Settings specified here will take precedence over those in config/application.rb.
^^^^^
config/application.rb:11:81: C: Line is too long. [82/80]
# Settings in config/environments/* take precedence over those specified here.
^^
config/puma.rb:7:27: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
^^^^^^^^^^^^^^^^^^^
config/puma.rb:10:81: C: Line is too long. [85/80]
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
^^^^^
config/puma.rb:12:23: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
port ENV.fetch("PORT") { 3000 }
^^^^^^
config/puma.rb:16:23: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
environment ENV.fetch("RAILS_ENV") { "development" }
^^^^^^^^^^^
config/puma.rb:16:38: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
environment ENV.fetch("RAILS_ENV") { "development" }
^^^^^^^^^^^^^
config/initializers/wrap_parameters.rb:6:81: C: Line is too long. [96/80]
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
^^^^^^^^^^^^^^^^
config/initializers/assets.rb:10:81: C: Line is too long. [93/80]
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
^^^^^^^^^^^^^
config/initializers/new_framework_defaults.rb:11:81: C: Line is too long. [81/80]
Rails.application.config.action_controller.forgery_protection_origin_check = true
^
config/initializers/new_framework_defaults.rb:20:81: C: Line is too long. [88/80]
# Do not halt callback chains when a callback returns false. Previous versions had true.
^^^^^^^^
config/initializers/new_framework_defaults.rb:23:81: C: Line is too long. [84/80]
# Configure SSL options to enable HSTS with subdomains. Previous versions had false.
^^^^
config/initializers/backtrace_silencers.rb:3:81: C: Line is too long. [107/80]
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
^^^^^^^^^^^^^^^^^^^^^^^^^^^
config/initializers/backtrace_silencers.rb:6:81: C: Line is too long. [112/80]
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
bin/spring:11:13: W: Assignment in condition - you probably meant to use ==.
if spring = lockfile.specs.detect { |spec| spec.name == "spring" }
^
bin/spring:11:59: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
if spring = lockfile.specs.detect { |spec| spec.name == "spring" }
^^^^^^^^
db/seeds.rb:1:81: C: Line is too long. [103/80]
# This file should contain all the record creation needed to seed the database with its default values.
^^^^^^^^^^^^^^^^^^^^^^^
db/seeds.rb:2:81: C: Line is too long. [111/80]
# The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup).
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
db/seeds.rb:6:81: C: Line is too long. [81/80]
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
^
app/controllers/home_controller.rb:1:1: C: Missing top-level class documentation comment.
class HomeController < ApplicationController
^^^^^
app/controllers/home_controller.rb:3:31: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
doc = Nokogiri::HTML(open("http://eslfuncast.libsyn.com/rss"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/controllers/home_controller.rb:8:31: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
doc = Nokogiri::HTML(open("http://eslfuncast.libsyn.com/rss"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
app/controllers/home_controller.rb:10:5: C: Do not use unless with else. Rewrite these with the positive case first.
unless link.nil? ...
^^^^^^^^^^^^^^^^
app/controllers/home_controller.rb:13:31: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
render json: { success: "" }
^^
app/controllers/application_controller.rb:1:1: C: Missing top-level class documentation comment.
class ApplicationController < ActionController::Base
^^^^^
app/models/application_record.rb:1:1: C: Missing top-level class documentation comment.
class ApplicationRecord < ActiveRecord::Base
^^^^^
app/helpers/home_helper.rb:1:1: C: Missing top-level module documentation comment.
module HomeHelper
^^^^^^
app/helpers/application_helper.rb:1:1: C: Missing top-level module documentation comment.
module ApplicationHelper
^^^^^^
app/mailers/application_mailer.rb:1:1: C: Missing top-level class documentation comment.
class ApplicationMailer < ActionMailer::Base
^^^^^
40 files inspected, 48 offenses detected
Even Fibonacci: wrong result of sum
Sum for Fibonacci numbers less than 4_000_000
cannot be less than 2_000_000
.
EvenFibonacci.new.sum
Expected Result: 4613732
Actual Result: 1762285
letter counter: Russian and Ukrainian letters
Please add ability to count Russian and Ukrainian letters also (including Ё
, І
and Ї
).
Beauty strings: make beauty a method of String
For example:
> 'a'.beauty
=> 26
Euler: palindrome
Iterating in reverse doesn't find the largest x*y, it finds the palindrome with the largest x. There's a larger answer than 580085; it has a smaller x but a larger y.
Expected Result: 906609
Actual Result: 580085
Poker homework: resolve RuboCop offenses
trainee-rep/homework$ rubocop
Inspecting 3 files
W.C
Offenses:
poker.rb:4:1: C: Class has too many lines. [113/100]
class Poker ...
^^^^^^^^^^^
poker.rb:4:1: C: Missing top-level class documentation comment.
class Poker
^^^^^
poker.rb:7:3: C: Replace class var @@combinations_list with a class instance var.
@@combinations_list = {
^^^^^^^^^^^^^^^^^^^
poker.rb:58:81: C: Line is too long. [83/80]
"Your winning combination is #{@@combinations_list[@position]} with Cards:\n" +
^^^
poker.rb:59:8: C: Omit parentheses for ternary conditions.
((@result.class == Card) ? @result.to_s : @result.each { |i| i.to_s }.join("\n"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
poker.rb:59:62: C: Pass &:to_s as an argument to each instead of a block.
((@result.class == Card) ? @result.to_s : @result.each { |i| i.to_s }.join("\n"))
^^^^^^^^^^^^^^
poker.rb:59:81: C: Line is too long. [87/80]
((@result.class == Card) ? @result.to_s : @result.each { |i| i.to_s }.join("\n"))
^^^^^^^
poker.rb:63:3: C: Cyclomatic complexity for check_for_royal is too high. [7/6]
def check_for_royal
^^^
poker.rb:63:3: C: Perceived complexity for check_for_royal is too high. [8/7]
def check_for_royal
^^^
poker.rb:77:25: W: Unused block argument - k. If it's necessary, use _ or _k as an argument name to indicate that it won't be used.
tmp ||= out.find { |k, v| v >= 5 }
^
poker.rb:82:3: C: Assignment Branch Condition size for check_for_straight is too high. [30.02/15]
def check_for_straight
^^^
poker.rb:82:3: C: Cyclomatic complexity for check_for_straight is too high. [7/6]
def check_for_straight
^^^
poker.rb:82:3: C: Method has too many lines. [16/10]
def check_for_straight ...
^^^^^^^^^^^^^^^^^^^^^^
poker.rb:88:5: C: Prefer each over for.
for i in 0..(arr.size - 5)
^^^
poker.rb:90:7: C: Prefer each over for.
for j in 1..4
^^^
poker.rb:91:9: C: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
if arr[i] - arr[j + i] != j
^^
poker.rb:98:36: W: Shadowing outer local variable - i.
winner(4, @all_cards.select { |i| (res.first..res.last).to_a.include?(i.rank.to_i) }) unless res.empty?
^
poker.rb:98:81: C: Line is too long. [107/80]
winner(4, @all_cards.select { |i| (res.first..res.last).to_a.include?(i.rank.to_i) }) unless res.empty?
^^^^^^^^^^^^^^^^^^^^^^^^^^^
poker.rb:109:7: W: Useless assignment to variable - pair.
pair = which_pair(out)
^^^^
poker.rb:119:3: C: Assignment Branch Condition size for which_pair is too high. [58.56/15]
def which_pair(h)
^^^
poker.rb:119:3: C: Cyclomatic complexity for which_pair is too high. [9/6]
def which_pair(h)
^^^
poker.rb:119:3: C: Method has too many lines. [13/10]
def which_pair(h) ...
^^^^^^^^^^^^^^^^^
poker.rb:119:3: C: Perceived complexity for which_pair is too high. [10/7]
def which_pair(h)
^^^
poker.rb:120:23: W: Unused block argument - k. If it's necessary, use _ or _k as an argument name to indicate that it won't be used.
tmp = h.select { |k, v| v >= 2 }
^
poker.rb:125:81: C: Line is too long. [99/80]
winner(6, @all_cards.select { |i| i.rank.to_i == tmp.keys[0] || i.rank.to_i == tmp.keys[1] })
^^^^^^^^^^^^^^^^^^^
poker.rb:129:81: C: Line is too long. [99/80]
winner(2, @all_cards.select { |i| i.rank.to_i == tmp.keys[0] || i.rank.to_i == tmp.keys[1] })
^^^^^^^^^^^^^^^^^^^
poker.rb:137:5: C: Use a guard clause instead of wrapping the code inside a conditional expression.
if @position < pos
^^
spec/poker_spec.rb:1:1: C: Carriage return character detected.
require('./poker') ...
^^^^^^^^^^^^^^^^^^
spec/poker_spec.rb:6:8: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
it "" do
^^
spec/poker_spec.rb:7:5: C: Use 2 (not 1) spaces for indentation.
expect { poker.finder("straight") }.to.contain("Iteration count")
^
spec/poker_spec.rb:7:28: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
expect { poker.finder("straight") }.to.contain("Iteration count")
^^^^^^^^^^
spec/poker_spec.rb:7:53: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
expect { poker.finder("straight") }.to.contain("Iteration count")
^^^^^^^^^^^^^^^^^
3 files inspected, 32 offenses detected
Euler: use snake case for ruby files
$ rubocop Euler/
Inspecting 1 file
C
Offenses:
Euler/multiples-of-3-and-5.rb:1:1: C: The name of this source file (multiples-of-3-and-5.rb) should use snake_case.
1 file inspected, 1 offense detected
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.