Bofh   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 18
loc 18
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A post_init() 7 7 1
A handle() 9 9 2

How to fix   Duplicated Code   

Duplicated Code

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
import urllib2
2
from event import Event
3
try:
4
  from basemodule import BaseModule
5
except ImportError:
6
  from modules.basemodule import BaseModule
7 View Code Duplication
class Bofh(BaseModule):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
8
  def post_init(self):
9
    b_event = Event("__.bofh__")
10
11
    b_event.define(msg_definition="^\.bofh")
12
    b_event.subscribe(self)
13
14
    self.bot.register_event(b_event, self)
15
16
  def handle(self, event):
17
    try:
18
      url = "http://zero9f9.com/api/bofh"
19
      response = urllib2.urlopen(url)
20
      text = response.read()
21
      bofhquote = text.splitlines()[2]
22
      self.say(event.channel, "BOFH: " + bofhquote)
23
    except:
24
      pass
25