| Total Complexity | 3 |
| Total Lines | 22 |
| Duplicated Lines | 100 % |
| Changes | 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 | const ApiService = Shopware.Classes.ApiService; |
||
| 8 | View Code Duplication | export default class PromotionCodeApiService extends ApiService { |
|
| 9 | constructor(httpClient, loginService, apiEndpoint = 'promotion') { |
||
| 10 | super(httpClient, loginService, apiEndpoint); |
||
| 11 | this.name = 'promotionCodeApiService'; |
||
| 12 | } |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @returns {Promise<T>} |
||
| 16 | */ |
||
| 17 | generateCodeFixed() { |
||
| 18 | const headers = this.getBasicHeaders(); |
||
| 19 | |||
| 20 | return this.httpClient.get( |
||
| 21 | `/_action/${this.getApiBasePath()}/codes/generate-fixed`, |
||
| 22 | { |
||
| 23 | headers |
||
| 24 | } |
||
| 25 | ).then((response) => { |
||
| 26 | return ApiService.handleResponse(response); |
||
| 27 | }); |
||
| 28 | } |
||
| 29 | } |
||
| 30 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.