-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Rubocop for style guidelines #3
Merged
+193
−216
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# 80 characters is a nice goal, but not worth currently changing in existing | ||
# code for the sake of changing it to conform to a length set in 1928 (IBM). | ||
Metrics/LineLength: | ||
Max: 100 | ||
|
||
# These exceptions are good goals to attain, and probably will over time, | ||
# so periodic disabling and re-running to inspect values is suggested. | ||
|
||
Metrics/AbcSize: | ||
Max: 40 | ||
|
||
# TODO: As refactors continue, this should drop. However, the goal of | ||
# 10 lines in a method may be a little lofty. | ||
Metrics/MethodLength: | ||
Max: 36 | ||
|
||
# TODO: this is not compliant with the Ruby community style guide. We | ||
# should enable again this rule but it will change the public API because | ||
# we're using set_ methods. We should work on that because also Rails | ||
# honors this rule. | ||
Style/AccessorMethodName: | ||
Enabled: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
source 'https://rubygems.org' | ||
|
||
|
||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
require "bundler/gem_tasks" | ||
require 'bundler/gem_tasks' | ||
require 'rubocop/rake_task' | ||
require 'rake/testtask' | ||
|
||
Rake::TestTask.new(:test) do |task| | ||
task.libs << %w(test lib) | ||
task.test_files = FileList['test/**/*_test.rb'] | ||
end | ||
|
||
task :default => :test | ||
RuboCop::RakeTask.new(:rubocop) do |t| | ||
t.patterns = ['lib/**/*.rb', 'test/**/*.rb', 'Gemfile', 'Rakefile'] | ||
end | ||
|
||
task default: :test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,37 @@ | ||
|
||
require "ddtrace/tracer" | ||
require 'ddtrace/tracer' | ||
|
||
# Generate a fake trace with the given tracer. | ||
def trace(tracer) | ||
urls = ["/home", "/login", "/logout"] | ||
resource = urls.sample() | ||
urls = ['/home', '/login', '/logout'] | ||
resource = urls.sample | ||
|
||
# rake web request. | ||
tracer.trace("web.request", :service=>"web", :resource=>resource) do | ||
tracer.trace('web.request', service: 'web', resource: resource) do | ||
sleep rand(0..0.1) | ||
|
||
# fake query. | ||
tracer.trace("db.query", :service=>"db") do | ||
tracer.trace('db.query', service: 'db') do | ||
sleep rand(0..0.1) | ||
end | ||
|
||
# fake template. | ||
tracer.trace("web.template") do | ||
tracer.trace('web.template') do | ||
r = rand(0..1.0) | ||
if r < 0.25 | ||
1/0 | ||
end | ||
1 / 0 if r < 0.25 | ||
end | ||
end | ||
rescue ZeroDivisionError => e | ||
puts "error #{e}" | ||
puts "error #{e}" | ||
end | ||
|
||
# Generate fake traces. | ||
def run() | ||
tracer = Datadog::Tracer.new() | ||
def run | ||
tracer = Datadog::Tracer.new | ||
loop do | ||
trace(tracer) | ||
sleep 0.0001 | ||
puts "traced #{tracer.writer.stats()}" | ||
puts "traced #{tracer.writer.stats}" | ||
end | ||
end | ||
|
||
|
||
if __FILE__ == $0 | ||
run() | ||
end | ||
run if __FILE__ == $PROGRAM_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
|
||
module Datadog | ||
|
||
module Errors | ||
MSG = "error.msg" | ||
TYPE = "error.type" | ||
STACK = "error.stack" | ||
MSG = 'error.msg'.freeze | ||
TYPE = 'error.type'.freeze | ||
STACK = 'error.stack'.freeze | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,22 @@ | ||
|
||
|
||
require 'thread' | ||
|
||
module Datadog | ||
|
||
class SpanBuffer | ||
|
||
# Set the current active span. | ||
def set(span) | ||
Thread.current[:datadog_span] = span | ||
end | ||
|
||
# Return the current active span or nil. | ||
def get() | ||
return Thread.current[:datadog_span] | ||
def get | ||
Thread.current[:datadog_span] | ||
end | ||
|
||
# Pop the current active span. | ||
def pop() | ||
s = self.get() | ||
self.set(nil) | ||
return s | ||
def pop | ||
s = get | ||
set(nil) | ||
s | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are just dev deps right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Actually the tracer requires third-party libraries only for development: https://github.com/DataDog/dd-trace-rb/pull/3/files#diff-b06e29a984e208fededfd0c6e60ca9ecR35
When the GEM is created, these dependencies are not installed.