Total Complexity | 6 |
Total Lines | 35 |
Duplicated Lines | 22.86 % |
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 | module Rapis |
||
28 | # |
||
29 | class Logger < Logger |
||
30 | include Singleton |
||
31 | |||
32 | def initialize |
||
33 | super(STDERR) |
||
34 | |||
35 | self.formatter = proc do |_severity, _datetime, _progname, msg| |
||
36 | "#{msg}\n" |
||
37 | end |
||
38 | |||
39 | self.level = Logger::INFO |
||
40 | end |
||
41 | View Code Duplication | ||
|
|||
42 | def debug(msg, progname = nil, method_name = nil) |
||
43 | super(progname) { { method_name: method_name, message: msg } } |
||
44 | end |
||
45 | |||
46 | def info(msg) |
||
47 | super { Rapis::TermColor.green(msg) } |
||
48 | end |
||
49 | |||
50 | def warn(msg) |
||
51 | super { Rapis::TermColor.yellow(msg) } |
||
52 | end |
||
53 | |||
54 | def fatal(msg) |
||
55 | super { Rapis::TermColor.red(msg) } |
||
56 | end |
||
57 | View Code Duplication | ||
58 | def error(msg, backtrace, progname = nil, method_name = nil) |
||
59 | super(progname) do |
||
60 | { method_name: method_name, message: msg, backtrace: backtrace } |
||
61 | end |
||
62 | end |
||
63 | end |
||
65 |