Esempio n. 1
0
    def get_cyclomatic_complexity(file_r, extension):
        is_inside_comment = False
        cc_counter = 0

        entry_tokens = None
        exit_tokens = None

        for i in __metric_cc_tokens__:
            if extension in i[0]:
                entry_tokens = i[1]
                exit_tokens = i[2]

        if entry_tokens or exit_tokens:
            for i in file_r:
                i = i.decode("utf-8", "replace")
                (_, is_inside_comment) = comment.handle_comment_block(is_inside_comment, extension, i)

                if not is_inside_comment and not comment.is_comment(extension, i):
                    for t in entry_tokens:
                        if re.search(t, i, re.DOTALL):
                            cc_counter += 2
                    for t in exit_tokens:
                        if re.search(t, i, re.DOTALL):
                            cc_counter += 1
            return cc_counter;

        return -1
Esempio n. 2
0
    def get_cyclomatic_complexity(file_r, extension):
        is_inside_comment = False
        cc_counter = 0

        entry_tokens = None
        exit_tokens = None

        for i in __metric_cc_tokens__:
            if extension in i[0]:
                entry_tokens = i[1]
                exit_tokens = i[2]

        if entry_tokens or exit_tokens:
            for i in file_r:
                i = i.decode("utf-8", "replace")
                (_, is_inside_comment) = comment.handle_comment_block(
                    is_inside_comment, extension, i)

                if not is_inside_comment and not comment.is_comment(
                        extension, i):
                    for t in entry_tokens:
                        if re.search(t, i, re.DOTALL):
                            cc_counter += 2
                    for t in exit_tokens:
                        if re.search(t, i, re.DOTALL):
                            cc_counter += 1
            return cc_counter

        return -1
Esempio n. 3
0
	def run(self):
		git_blame_r = subprocess.Popen(self.blame_string, shell=True, bufsize=1, stdout=subprocess.PIPE).stdout
		is_inside_comment = False

		for j in git_blame_r.readlines():
			j = j.decode("utf-8", "replace")
			if Blame.is_blame_line(j):
				author = Blame.get_author(j)
				content = Blame.get_content(j)
				__blame_lock__.acquire() # Global lock used to protect calls from here...

				if self.blames.get((author, self.filename), None) == None:
					self.blames[(author, self.filename)] = BlameEntry()

				if comment.is_comment(self.extension, content):
					self.blames[(author, self.filename)].comments += 1
				if is_inside_comment:
					if comment.has_comment_end(self.extension, content):
						is_inside_comment = False
					else:
						self.blames[(author, self.filename)].comments += 1
				elif comment.has_comment_begining(self.extension, content):
					is_inside_comment = True

				self.blames[(author, self.filename)].rows += 1
				__blame_lock__.release() # ...to here.

		git_blame_r.close()
		__thread_lock__.release() # Lock controlling the number of threads running
Esempio n. 4
0
    def get_eloc(file_r, extension):
        is_inside_comment = False
        eloc_counter = 0

        for i in file_r:
            i = i.decode("utf-8", "replace")
            (_, is_inside_comment) = comment.handle_comment_block(is_inside_comment, extension, i)

            if not is_inside_comment and not comment.is_comment(extension, i):
                eloc_counter += 1

        return eloc_counter
    def get_eloc(file_r, extension):
        is_inside_comment = False
        eloc_counter = 0

        for j in file_r.readlines():
            j = j.decode("utf-8", "replace")
            (_, is_inside_comment) = comment.handle_comment_block(is_inside_comment, extension, j)

            if not is_inside_comment and not comment.is_comment(extension, j):
                eloc_counter += 1

        return eloc_counter
Esempio n. 6
0
	def get_eloc(file_r, extension):
		is_inside_comment = False
		eloc_counter = 0

		for i in file_r:
			i = i.decode("utf-8", "replace")
			(_, is_inside_comment) = comment.handle_comment_block(is_inside_comment, extension, i)

			if not is_inside_comment and not comment.is_comment(extension, i):
				eloc_counter += 1

		return eloc_counter
Esempio n. 7
0
    def get_eloc(file_r, extension):
        is_inside_comment = False
        eloc_counter = 0

        for j in file_r.readlines():
            j = j.decode("utf-8", "replace")
            (_, is_inside_comment) = comment.handle_comment_block(
                is_inside_comment, extension, j)

            if not is_inside_comment and not comment.is_comment(extension, j):
                eloc_counter += 1

        return eloc_counter
	def get_eloc(file_r, extension):
		is_inside_comment = False
		eloc_counter = 0

		for j in file_r.readlines():
			j = j.decode("utf-8", "replace")
			if is_inside_comment and comment.has_comment_end(extension, j):
				is_inside_comment = False
			elif comment.has_comment_begining(extension, j):
				is_inside_comment = True

			if not is_inside_comment and not comment.is_comment(extension, j):
				eloc_counter += 1

		return eloc_counter
Esempio n. 9
0
    def get_eloc(file_r, extension):
        is_inside_comment = False
        eloc_counter = 0

        for j in file_r.readlines():
            j = j.decode("utf-8", "replace")
            if is_inside_comment and comment.has_comment_end(extension, j):
                is_inside_comment = False
            elif comment.has_comment_begining(extension, j):
                is_inside_comment = True

            if not is_inside_comment and not comment.is_comment(extension, j):
                eloc_counter += 1

        return eloc_counter