| Conditions | 10 |
| Total Lines | 20 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Complex classes like logger.ConvertSentryLevel often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
| 1 | package logger |
||
| 14 | func ConvertSentryLevel(level zapcore.Level) sentry.Level { |
||
| 15 | switch level { |
||
| 16 | case zapcore.InvalidLevel: |
||
| 17 | return sentry.LevelFatal |
||
| 18 | case zapcore.DebugLevel: |
||
| 19 | return sentry.LevelDebug |
||
| 20 | case zapcore.InfoLevel: |
||
| 21 | return sentry.LevelInfo |
||
| 22 | case zapcore.WarnLevel: |
||
| 23 | return sentry.LevelWarning |
||
| 24 | case zapcore.ErrorLevel: |
||
| 25 | return sentry.LevelError |
||
| 26 | case zapcore.DPanicLevel: |
||
| 27 | return sentry.LevelFatal |
||
| 28 | case zapcore.PanicLevel: |
||
| 29 | return sentry.LevelFatal |
||
| 30 | case zapcore.FatalLevel: |
||
| 31 | return sentry.LevelFatal |
||
| 32 | default: |
||
| 33 | return sentry.LevelFatal |
||
| 34 | } |
||
| 59 |