diff --git a/.github/workflows/add-milestone-to-pull-requests.yml b/.github/workflows/add-milestone-to-pull-requests.yml index fed57269..2ff00b17 100644 --- a/.github/workflows/add-milestone-to-pull-requests.yml +++ b/.github/workflows/add-milestone-to-pull-requests.yml @@ -10,7 +10,7 @@ jobs: steps: - name: Checkout code # Checks out the branch that the pull request is merged into - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.base.ref }} diff --git a/.github/workflows/build-gem.yml b/.github/workflows/build-gem.yml index 626c987a..af52a690 100644 --- a/.github/workflows/build-gem.yml +++ b/.github/workflows/build-gem.yml @@ -28,9 +28,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 - - uses: ruby/setup-ruby@31a7f6d628878b80bc63375a93ae079ec50a1601 # v1.143.0 + - uses: ruby/setup-ruby@v1 with: - ruby-version: '3.2' + ruby-version: '3.3' bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Patch version if: ${{ matrix.type != 'final' }} @@ -120,9 +120,9 @@ jobs: - name: List gem run: | find pkg - - uses: ruby/setup-ruby@31a7f6d628878b80bc63375a93ae079ec50a1601 # v1.143.0 + - uses: ruby/setup-ruby@v1 with: - ruby-version: '3.2' + ruby-version: '3.3' - name: Install gem run: | gem install pkg/*.gem diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index ea256174..b2949916 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -11,9 +11,9 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@31a7f6d628878b80bc63375a93ae079ec50a1601 # v1.143.0 + - uses: ruby/setup-ruby@v1 with: - ruby-version: '3.2' + ruby-version: '3.3' bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Check for stale signature files run: bundle exec rake rbs:stale diff --git a/.github/workflows/datadog-sca.yml b/.github/workflows/datadog-sca.yml new file mode 100644 index 00000000..7e7b1d23 --- /dev/null +++ b/.github/workflows/datadog-sca.yml @@ -0,0 +1,25 @@ +on: [push] + +name: Datadog Software Composition Analysis + +jobs: + software-composition-analysis: + runs-on: ubuntu-latest + name: Datadog SBOM Generation and Upload + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + ruby-version: '3.3' + - name: Check imported libraries are secure and compliant + id: datadog-software-composition-analysis + uses: DataDog/datadog-sca-github-action@main + with: + dd_api_key: ${{ secrets.DD_API_KEY }} + dd_app_key: ${{ secrets.DD_APP_KEY }} + dd_service: my-app + dd_env: ci + dd_site: datadoghq.com diff --git a/.github/workflows/datadog-static-analysis.yml b/.github/workflows/datadog-static-analysis.yml new file mode 100644 index 00000000..be35a97f --- /dev/null +++ b/.github/workflows/datadog-static-analysis.yml @@ -0,0 +1,21 @@ +on: [push] + +name: Datadog Static Analysis + +jobs: + static-analysis: + runs-on: ubuntu-latest + name: Datadog Static Analyzer + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Check code meets quality and security standards + id: datadog-static-analysis + uses: DataDog/datadog-static-analyzer-github-action@v1 + with: + dd_api_key: ${{ secrets.DD_API_KEY }} + dd_app_key: ${{ secrets.DD_APP_KEY }} + dd_service: datadog-ci-rb + dd_env: ci + dd_site: datadoghq.com + cpu_count: 2 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9f4522c4..f5a9fc67 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,5 +21,5 @@ jobs: uses: ruby/setup-ruby@v1 with: bundler-cache: true - ruby-version: '3.2.4' + ruby-version: '3.3' - uses: rubygems/release-gem@v1 diff --git a/.github/workflows/yard.yml b/.github/workflows/yard.yml index 30f63046..800d5fd8 100644 --- a/.github/workflows/yard.yml +++ b/.github/workflows/yard.yml @@ -30,7 +30,7 @@ jobs: uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: '3.2' + ruby-version: '3.3' bundler-cache: true - name: Generate YARD documentation run: bundle exec rake docs diff --git a/Appraisals b/Appraisals index 87ae4f44..b23fbbac 100644 --- a/Appraisals +++ b/Appraisals @@ -3,27 +3,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) module DisableBundleCheck def check_command - ["bundle", "exec", "false"] + %w[bundle exec false] end end -if ["true", "y", "yes", "1"].include?(ENV["APPRAISAL_SKIP_BUNDLE_CHECK"]) +if %w[true y yes 1].include?(ENV["APPRAISAL_SKIP_BUNDLE_CHECK"]) ::Appraisal::Appraisal.prepend(DisableBundleCheck) end alias original_appraise appraise REMOVED_GEMS = { - check: [ - "rbs", - "steep" - ], - development: [ - "ruby-lsp", - "ruby-lsp-rspec", - "debug", - "irb" - ] + check: %w[rbs steep], + development: %w[ruby-lsp ruby-lsp-rspec debug irb] } def appraise(group, &block) diff --git a/lib/datadog/ci/codeowners/matcher.rb b/lib/datadog/ci/codeowners/matcher.rb index 5b77b7bf..e515a365 100644 --- a/lib/datadog/ci/codeowners/matcher.rb +++ b/lib/datadog/ci/codeowners/matcher.rb @@ -87,7 +87,7 @@ def expand_pattern(pattern) return pattern if pattern == "*" # if pattern ends with a slash then it matches everything deeply nested in this directory - pattern += "**" if pattern.end_with?(::File::SEPARATOR) + pattern << "**" if pattern.end_with?(::File::SEPARATOR) # if pattern doesn't start with a slash then it matches anywhere in the repository if !pattern.start_with?(::File::SEPARATOR, "**#{::File::SEPARATOR}", "*#{::File::SEPARATOR}") diff --git a/lib/datadog/ci/codeowners/parser.rb b/lib/datadog/ci/codeowners/parser.rb index 60be8786..8a711fac 100644 --- a/lib/datadog/ci/codeowners/parser.rb +++ b/lib/datadog/ci/codeowners/parser.rb @@ -8,11 +8,11 @@ module Codeowners # Responsible for parsing a CODEOWNERS file class Parser DEFAULT_LOCATION = "CODEOWNERS" - POSSIBLE_CODEOWNERS_LOCATIONS = [ - "CODEOWNERS", - ".github/CODEOWNERS", - ".gitlab/CODEOWNERS", - "docs/CODEOWNERS" + POSSIBLE_CODEOWNERS_LOCATIONS = %w[ + CODEOWNERS + .github/CODEOWNERS + .gitlab/CODEOWNERS + docs/CODEOWNERS ].freeze def initialize(root_file_path) diff --git a/lib/datadog/ci/contrib/cucumber/formatter.rb b/lib/datadog/ci/contrib/cucumber/formatter.rb index 14134e3b..e105ddac 100644 --- a/lib/datadog/ci/contrib/cucumber/formatter.rb +++ b/lib/datadog/ci/contrib/cucumber/formatter.rb @@ -187,7 +187,7 @@ def extract_parameters_hash(test_case) def ok?(result, strict) # in minor update in Cucumber 9.2.0, the arity of the `ok?` method changed parameters = result.method(:ok?).parameters - if parameters == [[:opt, :be_strict]] + if parameters == [%i[opt be_strict]] result.ok?(strict) else result.ok?(strict: strict) diff --git a/lib/datadog/ci/contrib/rspec/example.rb b/lib/datadog/ci/contrib/rspec/example.rb index f6703fe0..01285280 100644 --- a/lib/datadog/ci/contrib/rspec/example.rb +++ b/lib/datadog/ci/contrib/rspec/example.rb @@ -23,7 +23,7 @@ def run(*args) test_name = full_description.strip if metadata[:description].empty? # for unnamed it blocks this appends something like "example at ./spec/some_spec.rb:10" - test_name += " #{description}" + test_name << " #{description}" end test_suite_description = fetch_top_level_example_group[:description] @@ -33,7 +33,7 @@ def run(*args) test_name = test_name.sub(test_suite_description, "").strip if ci_queue? - suite_name += " (ci-queue running example [#{test_name}])" + suite_name = "#{suite_name} (ci-queue running example [#{test_name}])" test_suite_span = CI.start_test_suite(suite_name) end @@ -83,9 +83,12 @@ def run(*args) private def fetch_top_level_example_group - return metadata[:example_group] unless metadata[:example_group][:parent_example_group] + example_group = metadata[:example_group] + parent_example_group = example_group[:parent_example_group] - res = metadata[:example_group][:parent_example_group] + return example_group unless parent_example_group + + res = parent_example_group while (parent = res[:parent_example_group]) res = parent end diff --git a/lib/datadog/ci/ext/environment.rb b/lib/datadog/ci/ext/environment.rb index e2fa1b8e..d301cf92 100644 --- a/lib/datadog/ci/ext/environment.rb +++ b/lib/datadog/ci/ext/environment.rb @@ -23,10 +23,7 @@ module Environment TAG_NODE_NAME = "ci.node.name" TAG_CI_ENV_VARS = "_dd.ci.env_vars" - POSSIBLE_BUNDLE_LOCATIONS = [ - "vendor/bundle", - ".bundle" - ].freeze + POSSIBLE_BUNDLE_LOCATIONS = %w[vendor/bundle .bundle].freeze module_function diff --git a/lib/datadog/ci/ext/environment/providers/gitlab.rb b/lib/datadog/ci/ext/environment/providers/gitlab.rb index 6668ee69..e0581083 100644 --- a/lib/datadog/ci/ext/environment/providers/gitlab.rb +++ b/lib/datadog/ci/ext/environment/providers/gitlab.rb @@ -75,12 +75,12 @@ def git_tag end def git_commit_author_name - name, _ = extract_name_email + name, _email = extract_name_email name end def git_commit_author_email - _, email = extract_name_email + _name, email = extract_name_email email end diff --git a/lib/datadog/ci/ext/settings.rb b/lib/datadog/ci/ext/settings.rb index a1921f6e..917fdb33 100644 --- a/lib/datadog/ci/ext/settings.rb +++ b/lib/datadog/ci/ext/settings.rb @@ -15,13 +15,13 @@ module Settings ENV_ITR_CODE_COVERAGE_EXCLUDED_BUNDLE_PATH = "DD_CIVISIBILITY_ITR_CODE_COVERAGE_EXCLUDED_BUNDLE_PATH" # Source: https://docs.datadoghq.com/getting_started/site/ - DD_SITE_ALLOWLIST = [ - "datadoghq.com", - "us3.datadoghq.com", - "us5.datadoghq.com", - "datadoghq.eu", - "ddog-gov.com", - "ap1.datadoghq.com" + DD_SITE_ALLOWLIST = %w[ + datadoghq.com + us3.datadoghq.com + us5.datadoghq.com + datadoghq.eu + ddog-gov.com + ap1.datadoghq.com ].freeze end end diff --git a/lib/datadog/ci/itr/coverage/event.rb b/lib/datadog/ci/itr/coverage/event.rb index 6e3d2a95..1e4815ea 100644 --- a/lib/datadog/ci/itr/coverage/event.rb +++ b/lib/datadog/ci/itr/coverage/event.rb @@ -21,7 +21,7 @@ def initialize(test_id:, test_suite_id:, test_session_id:, coverage:) def valid? valid = true - [:test_id, :test_suite_id, :test_session_id, :coverage].each do |key| + %i[test_id test_suite_id test_session_id coverage].each do |key| next unless send(key).nil? Datadog.logger.warn("citestcov event is invalid: [#{key}] is nil. Event: #{self}") diff --git a/lib/datadog/ci/test_visibility/serializers/base.rb b/lib/datadog/ci/test_visibility/serializers/base.rb index 24fe9777..0872e648 100644 --- a/lib/datadog/ci/test_visibility/serializers/base.rb +++ b/lib/datadog/ci/test_visibility/serializers/base.rb @@ -20,13 +20,7 @@ class Base "type" => "span_type" ].freeze - REQUIRED_FIELDS = [ - "error", - "name", - "resource", - "start", - "duration" - ].freeze + REQUIRED_FIELDS = %w[error name resource start duration].freeze attr_reader :trace, :span, :meta, :options diff --git a/lib/datadog/ci/test_visibility/serializers/span.rb b/lib/datadog/ci/test_visibility/serializers/span.rb index 07caefe2..d3b2b66f 100644 --- a/lib/datadog/ci/test_visibility/serializers/span.rb +++ b/lib/datadog/ci/test_visibility/serializers/span.rb @@ -7,11 +7,11 @@ module CI module TestVisibility module Serializers class Span < Base - CONTENT_FIELDS = (["trace_id", "span_id", "parent_id"] + Base::CONTENT_FIELDS).freeze + CONTENT_FIELDS = (%w[trace_id span_id parent_id] + Base::CONTENT_FIELDS).freeze CONTENT_MAP_SIZE = calculate_content_map_size(CONTENT_FIELDS) - REQUIRED_FIELDS = (["trace_id", "span_id"] + Base::REQUIRED_FIELDS).freeze + REQUIRED_FIELDS = (%w[trace_id span_id] + Base::REQUIRED_FIELDS).freeze def content_fields CONTENT_FIELDS diff --git a/lib/datadog/ci/test_visibility/serializers/test_module.rb b/lib/datadog/ci/test_visibility/serializers/test_module.rb index 385367a1..a37cb42f 100644 --- a/lib/datadog/ci/test_visibility/serializers/test_module.rb +++ b/lib/datadog/ci/test_visibility/serializers/test_module.rb @@ -8,11 +8,11 @@ module CI module TestVisibility module Serializers class TestModule < Base - CONTENT_FIELDS = (["test_session_id", "test_module_id"] + Base::CONTENT_FIELDS).freeze + CONTENT_FIELDS = (%w[test_session_id test_module_id] + Base::CONTENT_FIELDS).freeze CONTENT_MAP_SIZE = calculate_content_map_size(CONTENT_FIELDS) - REQUIRED_FIELDS = (["test_session_id", "test_module_id"] + Base::REQUIRED_FIELDS).freeze + REQUIRED_FIELDS = (%w[test_session_id test_module_id] + Base::REQUIRED_FIELDS).freeze def content_fields CONTENT_FIELDS diff --git a/lib/datadog/ci/test_visibility/serializers/test_session.rb b/lib/datadog/ci/test_visibility/serializers/test_session.rb index bbf0dd13..5ea4e0fe 100644 --- a/lib/datadog/ci/test_visibility/serializers/test_session.rb +++ b/lib/datadog/ci/test_visibility/serializers/test_session.rb @@ -8,11 +8,11 @@ module CI module TestVisibility module Serializers class TestSession < Base - CONTENT_FIELDS = (["test_session_id"] + Base::CONTENT_FIELDS).freeze + CONTENT_FIELDS = (%w[test_session_id] + Base::CONTENT_FIELDS).freeze CONTENT_MAP_SIZE = calculate_content_map_size(CONTENT_FIELDS) - REQUIRED_FIELDS = (["test_session_id"] + Base::REQUIRED_FIELDS).freeze + REQUIRED_FIELDS = (%w[test_session_id] + Base::REQUIRED_FIELDS).freeze def content_fields CONTENT_FIELDS diff --git a/lib/datadog/ci/test_visibility/serializers/test_suite.rb b/lib/datadog/ci/test_visibility/serializers/test_suite.rb index 8fcec2f1..5336e3d5 100644 --- a/lib/datadog/ci/test_visibility/serializers/test_suite.rb +++ b/lib/datadog/ci/test_visibility/serializers/test_suite.rb @@ -8,11 +8,11 @@ module CI module TestVisibility module Serializers class TestSuite < Base - CONTENT_FIELDS = (["test_session_id", "test_module_id", "test_suite_id"] + Base::CONTENT_FIELDS).freeze + CONTENT_FIELDS = (%w[test_session_id test_module_id test_suite_id] + Base::CONTENT_FIELDS).freeze CONTENT_MAP_SIZE = calculate_content_map_size(CONTENT_FIELDS) - REQUIRED_FIELDS = (["test_session_id", "test_module_id", "test_suite_id"] + Base::REQUIRED_FIELDS).freeze + REQUIRED_FIELDS = (%w[test_session_id test_module_id test_suite_id] + Base::REQUIRED_FIELDS).freeze def content_fields CONTENT_FIELDS diff --git a/lib/datadog/ci/test_visibility/serializers/test_v1.rb b/lib/datadog/ci/test_visibility/serializers/test_v1.rb index 0ab2b294..668afbed 100644 --- a/lib/datadog/ci/test_visibility/serializers/test_v1.rb +++ b/lib/datadog/ci/test_visibility/serializers/test_v1.rb @@ -8,11 +8,11 @@ module CI module TestVisibility module Serializers class TestV1 < Base - CONTENT_FIELDS = (["trace_id", "span_id"] + Base::CONTENT_FIELDS).freeze + CONTENT_FIELDS = (%w[trace_id span_id] + Base::CONTENT_FIELDS).freeze CONTENT_MAP_SIZE = calculate_content_map_size(CONTENT_FIELDS) - REQUIRED_FIELDS = (["trace_id", "span_id"] + Base::REQUIRED_FIELDS).freeze + REQUIRED_FIELDS = (%w[trace_id span_id] + Base::REQUIRED_FIELDS).freeze def content_fields CONTENT_FIELDS diff --git a/lib/datadog/ci/test_visibility/serializers/test_v2.rb b/lib/datadog/ci/test_visibility/serializers/test_v2.rb index ec026964..f1f674b1 100644 --- a/lib/datadog/ci/test_visibility/serializers/test_v2.rb +++ b/lib/datadog/ci/test_visibility/serializers/test_v2.rb @@ -8,15 +8,15 @@ module CI module TestVisibility module Serializers class TestV2 < TestV1 - CONTENT_FIELDS = (["test_session_id", "test_module_id", "test_suite_id"] + TestV1::CONTENT_FIELDS).freeze + CONTENT_FIELDS = (%w[test_session_id test_module_id test_suite_id] + TestV1::CONTENT_FIELDS).freeze - CONTENT_FIELDS_WITH_ITR_CORRELATION_ID = (CONTENT_FIELDS + ["itr_correlation_id"]).freeze + CONTENT_FIELDS_WITH_ITR_CORRELATION_ID = (CONTENT_FIELDS + %w[itr_correlation_id]).freeze CONTENT_MAP_SIZE = calculate_content_map_size(CONTENT_FIELDS) CONTENT_MAP_SIZE_WITH_ITR_CORRELATION_ID = calculate_content_map_size(CONTENT_FIELDS_WITH_ITR_CORRELATION_ID) - REQUIRED_FIELDS = (["test_session_id", "test_module_id", "test_suite_id"] + TestV1::REQUIRED_FIELDS).freeze + REQUIRED_FIELDS = (%w[test_session_id test_module_id test_suite_id] + TestV1::REQUIRED_FIELDS).freeze def content_fields return CONTENT_FIELDS if itr_correlation_id.nil? diff --git a/lib/datadog/ci/transport/http.rb b/lib/datadog/ci/transport/http.rb index 2a1e6f43..6069c9d4 100644 --- a/lib/datadog/ci/transport/http.rb +++ b/lib/datadog/ci/transport/http.rb @@ -124,6 +124,7 @@ def trace_count def gzipped?(payload) return false if payload.nil? || payload.empty? + # no-dd-sa first_bytes = payload[0, 2] return false if first_bytes.nil? || first_bytes.empty? diff --git a/sig/datadog/ci/codeowners/parser.rbs b/sig/datadog/ci/codeowners/parser.rbs index 15f064eb..7a80bc19 100644 --- a/sig/datadog/ci/codeowners/parser.rbs +++ b/sig/datadog/ci/codeowners/parser.rbs @@ -6,7 +6,7 @@ module Datadog DEFAULT_LOCATION: "CODEOWNERS" - POSSIBLE_CODEOWNERS_LOCATIONS: ::Array["CODEOWNERS" | ".github/CODEOWNERS" | ".gitlab/CODEOWNERS" | "docs/CODEOWNERS"] + POSSIBLE_CODEOWNERS_LOCATIONS: Array[String] def initialize: (String? root_file_path) -> void diff --git a/spec/datadog/ci/contrib/ci_queue_minitest/instrumentation_spec.rb b/spec/datadog/ci/contrib/ci_queue_minitest/instrumentation_spec.rb index 013aa2ca..0e4d67a8 100644 --- a/spec/datadog/ci/contrib/ci_queue_minitest/instrumentation_spec.rb +++ b/spec/datadog/ci/contrib/ci_queue_minitest/instrumentation_spec.rb @@ -1,5 +1,6 @@ require "minitest/queue/runner" require "fileutils" +require "securerandom" RSpec.describe "Minitest instrumentation with Shopify's ci-queue runner" do include_context "CI mode activated" do @@ -7,7 +8,7 @@ let(:integration_options) { {service_name: "ltest"} } end - let(:run_id) { rand(1..2**64 - 1) } + let(:run_id) { SecureRandom.random_number(2**64 - 1) } before do Minitest::Runnable.reset diff --git a/spec/datadog/ci/contrib/ci_queue_rspec/instrumentation_spec.rb b/spec/datadog/ci/contrib/ci_queue_rspec/instrumentation_spec.rb index 9e02bbf6..1da3a821 100644 --- a/spec/datadog/ci/contrib/ci_queue_rspec/instrumentation_spec.rb +++ b/spec/datadog/ci/contrib/ci_queue_rspec/instrumentation_spec.rb @@ -1,12 +1,13 @@ require "rspec/queue" require "fileutils" +require "securerandom" RSpec.describe "RSpec instrumentation with Shopify's ci-queue runner" do include_context "CI mode activated" do let(:integration_name) { :rspec } end - let(:run_id) { rand(1..2**64 - 1) } + let(:run_id) { SecureRandom.random_number(2**64 - 1) } let(:options) do RSpec::Core::ConfigurationOptions.new([ "-Ispec/datadog/ci/contrib/ci_queue_rspec/suite_under_test", diff --git a/spec/datadog/ci/contrib/cucumber/instrumentation_spec.rb b/spec/datadog/ci/contrib/cucumber/instrumentation_spec.rb index 3b23acdc..8ff61f98 100644 --- a/spec/datadog/ci/contrib/cucumber/instrumentation_spec.rb +++ b/spec/datadog/ci/contrib/cucumber/instrumentation_spec.rb @@ -1,6 +1,7 @@ require "stringio" require "fileutils" require "cucumber" +require "securerandom" RSpec.describe "Cucumber formatter" do let(:cucumber_features_root) { File.join(__dir__, "features") } @@ -22,7 +23,7 @@ let(:cucumber_8_or_above) { Gem::Version.new("8.0.0") <= Datadog::CI::Contrib::Cucumber::Integration.version } let(:cucumber_4_or_above) { Gem::Version.new("4.0.0") <= Datadog::CI::Contrib::Cucumber::Integration.version } - let(:run_id) { rand(1..2**64 - 1) } + let(:run_id) { SecureRandom.random_number(2**64 - 1) } let(:steps_file_definition_path) { "spec/datadog/ci/contrib/cucumber/features/step_definitions/steps.rb" } let(:steps_file_for_run_path) do "spec/datadog/ci/contrib/cucumber/features/step_definitions/steps_#{run_id}.rb" diff --git a/spec/datadog/ci/test_visibility/context/global_spec.rb b/spec/datadog/ci/test_visibility/context/global_spec.rb index 72cc669f..4fcb0fc5 100644 --- a/spec/datadog/ci/test_visibility/context/global_spec.rb +++ b/spec/datadog/ci/test_visibility/context/global_spec.rb @@ -207,7 +207,7 @@ context "when multiple test suites are running" do before do - ["suite1", "suite2"].each do |test_suite_name| + %w[suite1 suite2].each do |test_suite_name| subject.fetch_or_activate_test_suite(test_suite_name) do Datadog::CI::TestSuite.new(double(Datadog::Tracing::SpanOperation)) end diff --git a/spec/support/contexts/msgpack_serializer.rb b/spec/support/contexts/msgpack_serializer.rb index eec6fc9d..df38dc75 100644 --- a/spec/support/contexts/msgpack_serializer.rb +++ b/spec/support/contexts/msgpack_serializer.rb @@ -5,11 +5,7 @@ subject {} let(:msgpack_jsons) do - if subject.is_a?(Array) - subject.map { |s| MessagePack.unpack(MessagePack.pack(s)) } - else - [MessagePack.unpack(MessagePack.pack(subject))] - end + Array(subject).map { |s| MessagePack.unpack(MessagePack.pack(s)) } end let(:msgpack_json) { msgpack_jsons.first } diff --git a/spec/support/span_helpers.rb b/spec/support/span_helpers.rb index d3d81190..58515b48 100644 --- a/spec/support/span_helpers.rb +++ b/spec/support/span_helpers.rb @@ -118,7 +118,7 @@ def description_of(actual) # rubocop:disable Lint/NestedMethodDefinition end end - ["skip", "pass", "fail"].each do |status| + %w[skip pass fail].each do |status| RSpec::Matchers.define "have_#{status}_status" do match do |span| @actual = span.get_tag(Datadog::CI::Ext::Test::TAG_STATUS) diff --git a/static-analysis.datadog.yml b/static-analysis.datadog.yml index 67a2b9d4..9a7ffd51 100644 --- a/static-analysis.datadog.yml +++ b/static-analysis.datadog.yml @@ -1,6 +1,18 @@ +schema-version: v1 rulesets: - ruby-code-style - ruby-security - - ruby-best-practices - - rails-best-practices -ignorePaths: [] + - ruby-best-practices: + rules: + symbols-as-keys: + ignore: + - '**' + hash-fetch: + ignore: + - '**' + percent-w: + ignore: + - spec/**/* + no-optional-hash-params: + ignore: + - '**' diff --git a/yard/extensions.rb b/yard/extensions.rb index 00585bce..e3232bb8 100644 --- a/yard/extensions.rb +++ b/yard/extensions.rb @@ -65,7 +65,7 @@ class DatadogConfigurationSettingsHandler < YARD::Handlers::Ruby::Base process do next if statement.is_a?(YARD::Parser::Ruby::ReferenceNode) - name = call_params[0] + name = call_params.first # Check if we are already nested inside the DSL namespace if namespace.has_tag?(:dsl) @@ -131,6 +131,7 @@ class DatadogConfigurationOptionHandler < YARD::Handlers::Ruby::Base end end +# no-dd-sa def camelize(str) str.split("_").collect(&:capitalize).join end diff --git a/yard/templates/default/docstring/setup.rb b/yard/templates/default/docstring/setup.rb index 4e0b22ff..612564aa 100644 --- a/yard/templates/default/docstring/setup.rb +++ b/yard/templates/default/docstring/setup.rb @@ -5,6 +5,7 @@ # sections :index, [:private, :deprecated, :abstract, :todo, :note, :returns_void, :text], T('tags') # end +# no-dd-sa def deprecated return unless object.has_tag?(:deprecated)