| Total Complexity | 2 |
| Total Lines | 25 |
| Duplicated Lines | 100 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | # frozen_string_literal: true |
||
| 13 | class Add < Action |
||
| 14 | attr_accessor :account |
||
| 15 | attr_accessor :key |
||
| 16 | |||
| 17 | # @param [AMA::Chef::User::Model::Account] account |
||
| 18 | # @param [AMA::Chef::User::Model::PrivateKey] key |
||
| 19 | def initialize(account, key) |
||
| 20 | @account = account |
||
| 21 | @key = key |
||
| 22 | end |
||
| 23 | |||
| 24 | def apply(resource_factory) |
||
| 25 | account = @account |
||
| 26 | key = @key |
||
| 27 | name = "#{account.id}:#{key.owner}:#{key.id}" |
||
| 28 | resource_factory.ssh_private_key name do |
||
| 29 | id key.id.to_s |
||
| 30 | user account.id.to_s |
||
| 31 | content key.content.to_s |
||
| 32 | install_public_key key.install_public_key |
||
| 33 | passphrase key.passphrase unless key.passphrase.nil? |
||
| 34 | perform_validation key.validate |
||
| 35 | end |
||
| 36 | end |
||
| 37 | end |
||
| 38 | end |
||
| 44 |