Similar blocks of code found in 2 locations. Consider refactoring. Open
func SendTransactionRequest(input TransactionRequest) (*TransactionResponse, error) {
action := CreatePayment{
CreateTransactionRequest: CreateTransactionRequest{
MerchantAuthentication: GetAuthentication(),
TransactionRequest: input,
- Read upRead up
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 138.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
exported type LineItems should have comment or be unexported Open
type LineItems struct {
- Exclude checks
exported type Duty should have comment or be unexported Open
type Duty struct {
- Exclude checks
struct field RefTransId should be RefTransID Open
RefTransId string `json:"refTransId,omitempty"`
- Exclude checks
struct field RefId should be RefID Open
RefId string `json:"refTransId,omitempty"`
- Exclude checks
exported type TransactionResponse should have comment or be unexported Open
type TransactionResponse struct {
- Exclude checks
exported method NewTransaction.Charge should have comment or be unexported Open
func (tranx NewTransaction) Charge() (*TransactionResponse, error) {
- Exclude checks
exported function GetHostedPaymentPage should have comment or be unexported Open
func GetHostedPaymentPage() {
- Exclude checks
exported type PreviousTransaction should have comment or be unexported Open
type PreviousTransaction struct {
- Exclude checks
exported type UserField should have comment or be unexported Open
type UserField struct {
- Exclude checks
exported method PreviousTransaction.Void should have comment or be unexported Open
func (tranx PreviousTransaction) Void() (*TransactionResponse, error) {
- Exclude checks
exported function ChargeTokenCard should have comment or be unexported Open
func ChargeTokenCard() {
- Exclude checks
don't use MixedCaps in package name; AuthorizeCIM should be authorizecim Open
package AuthorizeCIM
- Exclude checks
struct field InvoiceId should be InvoiceID Open
InvoiceId string `json:"invoiceId,omitempty"`
- Exclude checks
exported type Payment should have comment or be unexported Open
type Payment struct {
- Exclude checks
exported function SendTransactionRequest should have comment or be unexported Open
func SendTransactionRequest(input TransactionRequest) (*TransactionResponse, error) {
- Exclude checks
exported type Setting should have comment or be unexported Open
type Setting struct {
- Exclude checks
exported type Tax should have comment or be unexported Open
type Tax struct {
- Exclude checks
exported method NewTransaction.AuthOnly should have comment or be unexported Open
func (tranx NewTransaction) AuthOnly() (*TransactionResponse, error) {
- Exclude checks
exported method PreviousTransaction.Capture should have comment or be unexported Open
func (tranx PreviousTransaction) Capture() (*TransactionResponse, error) {
- Exclude checks
exported type LineItem should have comment or be unexported Open
type LineItem struct {
- Exclude checks
exported function GetAccessPaymentPage should have comment or be unexported Open
func GetAccessPaymentPage() {
- Exclude checks
exported type MerchantAuthentication should have comment or be unexported Open
type MerchantAuthentication struct {
- Exclude checks
exported function UpdateSplitTenderGround should have comment or be unexported Open
func UpdateSplitTenderGround() {
- Exclude checks
exported function DebitBankAccount should have comment or be unexported Open
func DebitBankAccount() {
- Exclude checks
exported function CreditBankAccount should have comment or be unexported Open
func CreditBankAccount() {
- Exclude checks
exported type TransactionMessages should have comment or be unexported Open
type TransactionMessages struct {
- Exclude checks
exported type CreateTransactionRequest should have comment or be unexported Open
type CreateTransactionRequest struct {
- Exclude checks
exported function CreditAcceptPaymentTransaction should have comment or be unexported Open
func CreditAcceptPaymentTransaction() {
- Exclude checks
exported type TransactionSettings should have comment or be unexported Open
type TransactionSettings struct {
- Exclude checks
exported type UserFields should have comment or be unexported Open
type UserFields struct {
- Exclude checks
exported type Customer should have comment or be unexported Open
type Customer struct {
- Exclude checks
exported method NewTransaction.Refund should have comment or be unexported Open
func (tranx NewTransaction) Refund() (*TransactionResponse, error) {
- Exclude checks
exported type CreditCard should have comment or be unexported Open
type CreditCard struct {
- Exclude checks
exported type NewTransaction should have comment or be unexported Open
type NewTransaction struct {
- Exclude checks
exported method NewTransaction.ChargeProfile should have comment or be unexported Open
func (tranx NewTransaction) ChargeProfile(profile Customer) (*TransactionResponse, error) {
- Exclude checks
exported type TranxResponse should have comment or be unexported Open
type TranxResponse struct {
- Exclude checks
exported type Message should have comment or be unexported Open
type Message struct {
- Exclude checks
exported type CreatePayment should have comment or be unexported Open
type CreatePayment struct {
- Exclude checks
exported type Shipping should have comment or be unexported Open
type Shipping struct {
- Exclude checks
struct field RefTransId should be RefTransID Open
RefTransId string `json:"refTransId,omitempty"`
- Exclude checks
exported type Address should have comment or be unexported Open
type Address struct {
- Exclude checks
exported type TransactionRequest should have comment or be unexported Open
type TransactionRequest struct {
- Exclude checks