Skip to content

Commit

Permalink
Exclude repos that have descriptions shorter than 5 chars
Browse files Browse the repository at this point in the history
  • Loading branch information
jerodsanto committed Jan 26, 2024
1 parent f5456ab commit 8aa5a6c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/bq_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def response_to_repo_list query_result, limit
repo = Repo.from_github row[:url], row[:count]
next if repo.blocked?
next if repo.malware? # run it again now that we have more info
next if repo.no_description?
next if repo.description_too_short?
next if repo.description_too_long?
next if repo.obscene?
next if repo.too_many_new_stars?
Expand Down
4 changes: 2 additions & 2 deletions lib/repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def no_language?
(language || "").strip.empty?
end

def no_description?
description.strip.empty?
def description_too_short?
description.length < 5
end

def description_too_long?
Expand Down
33 changes: 19 additions & 14 deletions spec/repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@
end
end

describe "#description_too_short?" do
it "is true when description is nil, empty, or blank" do
[nil, "", " "].each do |bad|
repo.description = bad
expect(repo.description_too_short?).to be true
end
end

it "is true when descripton has short contents" do
repo.description = "ohai"
expect(repo.description_too_short?).to be true
end

it "is false when descripton has long contents" do
repo.description = "ohai this is a real one"
expect(repo.description_too_short?).to be false
end
end

describe "#description_too_long?" do
it "is true when longer than a tweet" do
repo.description = "0" * 281
Expand Down Expand Up @@ -105,20 +124,6 @@
end
end

describe "#no_description?" do
it "is true when description is nil, empty, or blank" do
[nil, "", " "].each do |bad|
repo.description = bad
expect(repo.no_description?).to be true
end
end

it "is false when descripton has contents" do
repo.description = "ohai"
expect(repo.no_description?).to be false
end
end

describe "#obscene?" do
before do
repo.owner = double login: ""
Expand Down

0 comments on commit 8aa5a6c

Please sign in to comment.