Total Complexity | 3 |
Total Lines | 21 |
Duplicated Lines | 66.67 % |
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 | # frozen_string_literal: true |
||
19 | class ErrorsController < ApplicationController |
||
20 | def not_found |
||
21 | render "greenlight_error", status: 404, formats: :html |
||
22 | end |
||
23 | |||
24 | View Code Duplication | def internal_error |
|
|
|||
25 | render "errors/greenlight_error", status: 500, formats: :html, |
||
26 | locals: { |
||
27 | status_code: 500, |
||
28 | message: I18n.t("errors.internal.message"), |
||
29 | help: I18n.t("errors.internal.help"), |
||
30 | display_back: true, |
||
31 | report_issue: true |
||
32 | } |
||
33 | end |
||
34 | |||
35 | View Code Duplication | def unauthorized |
|
36 | render "errors/greenlight_error", status: 401, formats: :html, locals: { status_code: 401, |
||
37 | message: I18n.t("errors.unauthorized.message"), help: I18n.t("errors.unauthorized.help"), display_back: true } |
||
38 | end |
||
39 | end |
||
40 |