decko-commons/decko

View on GitHub
mod/account/spec/set/type/signup_spec.rb

Summary

Maintainability
A
1 hr
Test Coverage

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

    it "creates all the necessary cards" do
      expect(@signup.type_id).to eq(Card::SignupID)
      expect(@account.email).to eq("wolf@decko.org")
      expect(@account.status).to eq("unapproved")
      expect(@account.salt).not_to eq("")
Severity: Minor
Found in mod/account/spec/set/type/signup_spec.rb and 1 other location - About 40 mins to fix
mod/account/spec/set/type/signup_spec.rb on lines 47..52

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 37.

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

    it "creates all the necessary cards" do
      expect(@signup.type_id).to eq(Card::SignupID)
      expect(@account.email).to eq("wolf@decko.org")
      expect(@account.status).to eq("unverified")
      expect(@account.salt).not_to eq("")
Severity: Minor
Found in mod/account/spec/set/type/signup_spec.rb and 1 other location - About 40 mins to fix
mod/account/spec/set/type/signup_spec.rb on lines 105..110

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 37.

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

Use let instead of an instance variable.
Open

      expect(@account.email).to eq("wolf@decko.org")

Start context description with 'when', 'with', or 'without'.
Open

  context "signup (without approval)" do

Use let instead of an instance variable.
Open

      @account = @signup.account

Use let instead of an instance variable.
Open

      expect(@account.status).to eq("unverified")

Use let instead of an instance variable.
Open

      expect(@account.salt).not_to eq("")

Use let instead of an instance variable.
Open

      @account = @signup.account

Use let instead of an instance variable.
Open

      expect(@account.password.length).to be > 10 # encrypted

Use let instead of an instance variable.
Open

      Card::Env.params[:token] = Card::Auth::Token.encode @signup.id, anonymous: true

Use let instead of an instance variable.
Open

      body = @mail.parts[0].body.raw_source

Use let instead of an instance variable.
Open

      expect(@signup.refresh(true).type_id).to eq(Card::UserID)

Use let instead of an instance variable.
Open

      expect(@account.salt).not_to eq("")

Start context description with 'when', 'with', or 'without'.
Open

  context "a welcome email card exists" do

Use let instead of an instance variable.
Open

        expect(@signup.account).to be_active

Use let instead of an instance variable.
Open

      account = @signup.account

Use let instead of an instance variable.
Open

      @account = @signup.account

Use let instead of an instance variable.
Open

      expect(@account.status).to eq("unverified")

Use let instead of an instance variable.
Open

        expect(body).to include(@signup.name)

Use let instead of an instance variable.
Open

      expect(@account.email).to eq("wolf@decko.org")

Use let instead of an instance variable.
Open

      expect(@account.password.length).to be > 10 # encrypted

Use let instead of an instance variable.
Open

        @signup.update! trigger: :approve_with_verification

Name your test subject if you need to reference it explicitly.
Open

        expect(subject.match(/Sign up/)).to be_truthy

Start context description with 'when', 'with', or 'without'.
Open

  context "signup form form" do

Use let instead of an instance variable.
Open

      expect(@signup.type_id).to eq(Card::SignupID)

Use let instead of an instance variable.
Open

        expect(@signup.format.render_core).to have_tag "div.invite-links" do

Use let instead of an instance variable.
Open

        expect(@signup.account.status).to eq("unverified")

Use let instead of an instance variable.
Open

      expect(@mail.body.raw_source).to include("Welcome Big Bad Sheep")

Start context description with 'when', 'with', or 'without'.
Open

  context "signup (with approval)" do

Use let instead of an instance variable.
Open

      expect(@account.status).to eq("unapproved")

Use let instead of an instance variable.
Open

      expect(@account.salt).not_to eq("")

Use let instead of an instance variable.
Open

        @signup.update! trigger: :approve_without_verification

Use let instead of an instance variable.
Open

        expect(@signup.type_id).to eq(Card::UserID)

Use let instead of an instance variable.
Open

      expect(@signup.type_id).to eq(Card::SignupID)

Use let instead of an instance variable.
Open

      expect(@signup.format.invitation?).to be(true)

Use let instead of an instance variable.
Open

        expect(@signup.type_id).to eq(Card::SignupID)

Use let instead of an instance variable.
Open

      expect(@signup.type_id).to eq(Card::SignupID)

Use let instead of an instance variable.
Open

      expect(@mail).to be_truthy

Start context description with 'when', 'with', or 'without'.
Open

  context "invitation" do

Use let instead of an instance variable.
Open

      @signup.update! trigger: :approve_without_verification

Use let instead of an instance variable.
Open

      expect(@account.email).to eq("wolf@decko.org")

There are no issues that match your filters.

Category
Status