mhenrixon/stub_requests

View on GitHub

Showing 70 of 71 total issues

Complex method describe##define_stubs (98.6)
Open

  describe "#define_stubs" do
    subject(:test_instance) { Testing.new }

    before do
      dsl.define_stubs
Severity: Minor
Found in spec/stub_requests/dsl_spec.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method describe##print_stubs (83.5)
Open

  describe "#print_stubs" do
    subject(:print_stubs) { dsl.print_stubs }

    let(:stub_person_documents_create) do
      a_string_including(<<~METHOD)
Severity: Minor
Found in spec/stub_requests/dsl_spec.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method describe##initialize (80.5)
Open

  describe "#initialize" do
    subject { service }

    its(:id) { is_expected.to eq(service_id) }
    its(:uri) { is_expected.to eq(service_uri) }
Severity: Minor
Found in spec/stub_requests/service_spec.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method describe(#build)::context#when endpoint has not replaced URI segments (66.0)
Open

    context "when endpoint has not replaced URI segments" do
      let(:path) { "another/:bogus/endpoint/:without_any/value" }

      specify do # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
        expect { build }.to raise_error do |error|
Severity: Minor
Found in spec/stub_requests/uri/builder_spec.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method describe(#build)::context#when endpoint has unused uri segments (66.0)
Open

    context "when endpoint has unused uri segments" do
      let(:route_params) { { rocks: :my_world, my_boat: :floats } }

      specify do # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
        expect { build }.to raise_error do |error|
Severity: Minor
Found in spec/stub_requests/uri/builder_spec.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method describe(#build)::describeconfiguration of WebMock::RequestStub (58.4)
Open

    describe "configuration of WebMock::RequestStub" do
      let(:request_stub) { WebMock::RequestStub.new(verb, uri) }

      before do
        allow(WebMock::RequestStub).to receive(:new).with(verb, uri).and_return(request_stub)

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method its#presence (42.1)
Open

  its(:presence) { is_expected.to eq(subject) }

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method describe(#to_s)::context#when endpoints are registered (37.7)
Open

    context "when endpoints are registered" do
      before { service.register(endpoint_id, verb, path) }

      let(:expected_output) do
        "#<StubRequests::Service id=abstractions uri=https://abstractions.com/v1 endpoints=[" \
Severity: Minor
Found in spec/stub_requests/service_spec.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method describe(#define_stubs)::describe(#stub_person_documents_patch)::it#stubs WebMock with the right request details (34.0)
Open

      it "stubs WebMock with the right request details" do
        test_instance.stub_person_documents_patch(person_id: 789, id: 321) do
          expect(self).to be_a(WebMock::RequestStub)
          expect(request_pattern.uri_pattern.to_s).to eq("https://domain.com/api/internal/persons/789/documents/321")
          expect(request_pattern.method_pattern.to_s).to eq("patch")
Severity: Minor
Found in spec/stub_requests/dsl_spec.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method describe(#define_stubs)::describe(#stub_person_documents_destroy)::it#stubs WebMock with the right request details (34.0)
Open

      it "stubs WebMock with the right request details" do
        test_instance.stub_person_documents_destroy(person_id: 789, id: 321) do
          expect(self).to be_a(WebMock::RequestStub)
          expect(request_pattern.uri_pattern.to_s).to eq("https://domain.com/api/internal/persons/789/documents/321")
          expect(request_pattern.method_pattern.to_s).to eq("delete")
Severity: Minor
Found in spec/stub_requests/dsl_spec.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method describe(#each)::context(when given a block)::it#delegates to @endpoints (33.4)
Open

      it "delegates to @endpoints" do
        block = ->(endpoint) { endpoint }
        allow(registry.endpoints).to receive(:each).and_call_original
        each(&block)
        expect(registry.endpoints).to have_received(:each).with(no_args, &block)

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method describe(#define_stubs)::describe(#stub_person_documents_show)::it#stubs WebMock with the right request details (33.2)
Open

      it "stubs WebMock with the right request details" do
        test_instance.stub_person_documents_show(person_id: "456", id: "123") do
          expect(self).to be_a(WebMock::RequestStub)
          expect(request_pattern.uri_pattern.to_s).to eq("https://domain.com/api/internal/persons/456/documents/123")
          expect(request_pattern.method_pattern.to_s).to eq("get")
Severity: Minor
Found in spec/stub_requests/dsl_spec.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method describe(#define_stubs)::describe(#stub_person_documents_create)::it#stubs WebMock with the right request details (33.2)
Open

      it "stubs WebMock with the right request details" do
        test_instance.stub_person_documents_create(person_id: "abcdef") do
          expect(self).to be_a(WebMock::RequestStub)
          expect(request_pattern.uri_pattern.to_s).to eq("https://domain.com/api/internal/persons/abcdef/documents")
          expect(request_pattern.method_pattern.to_s).to eq("post")
Severity: Minor
Found in spec/stub_requests/dsl_spec.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method describe(#define_stubs)::describe(#stub_person_documents_index)::it#stubs WebMock with the right request details (33.2)
Open

      it "stubs WebMock with the right request details" do
        test_instance.stub_person_documents_index(person_id: "631") do
          expect(self).to be_a(WebMock::RequestStub)
          expect(request_pattern.uri_pattern.to_s).to eq("https://domain.com/api/internal/persons/631/documents")
          expect(request_pattern.method_pattern.to_s).to eq("get")
Severity: Minor
Found in spec/stub_requests/dsl_spec.rb by flog

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method describe(#register)::context#with existing callbacks (31.4)
Open

    context "with existing callbacks" do
      before do
        registry.register(service_id, endpoint_id, verb, callback)
      end

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method describe(#remove)::context#when service is registered (29.3)
Open

    context "when service is registered" do
      before { registry.register(service_id, service_uri) }

      it! { is_expected.to change { registry.services.size }.from(1).to(0) }

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Complex method describe(#reset)::context#when services are registered (29.3)
Open

    context "when services are registered" do
      before { registry.register(service_id, service_uri) }

      it! { is_expected.to change { registry.services.size }.from(1).to(0) }

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      specify do # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
        expect { build }.to raise_error do |error|
          expect(error).to be_a(StubRequests::UriSegmentMismatch)
          expect(error.message).to include(
            "The URI (http://service-name:9292/internal/another/:bogus/endpoint)" \
Severity: Minor
Found in spec/stub_requests/uri/builder_spec.rb and 1 other location - About 55 mins to fix
spec/stub_requests/uri/builder_spec.rb on lines 39..50

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 46.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      specify do # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations
        expect { build }.to raise_error do |error|
          expect(error).to be_a(StubRequests::UriSegmentMismatch)
          expect(error.message).to include(
            "The URI (http://service-name:9292/internal/another/:bogus/endpoint/:without_any/value)" \
Severity: Minor
Found in spec/stub_requests/uri/builder_spec.rb and 1 other location - About 55 mins to fix
spec/stub_requests/uri/builder_spec.rb on lines 20..31

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 46.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Complex method describe(#unregister)::context#with existing callbacks (27.0)
Open

    context "with existing callbacks" do
      before do
        registry.register(service_id, endpoint_id, verb, callback)
      end

Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.

You can read more about ABC metrics or the flog tool

Severity
Category
Status
Source
Language