Exemplo 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
Exemplo 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
Exemplo n.º 3
0
    def __handle_blamechunk_content__(self, content):
        author = None
        (comments, self.is_inside_comment) = comment.handle_comment_block(
            self.is_inside_comment, self.extension, content)

        if self.blamechunk_is_prior and interval.get_since():
            return
        try:
            author = self.changes.get_latest_author_by_email(
                self.blamechunk_email)
        except KeyError:
            return

        if not filtering.set_filtered(author, "author") and not \
               filtering.set_filtered(self.blamechunk_email, "email") and not \
               filtering.set_filtered(self.blamechunk_revision, "revision"):

            __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()

            self.blames[(author, self.filename)].comments += comments
            self.blames[(author, self.filename)].rows += 1

            if (self.blamechunk_time -
                    self.changes.first_commit_date).days > 0:
                self.blames[(author, self.filename)].skew += (
                    (self.changes.last_commit_date - self.blamechunk_time).days
                    / (7.0 if self.useweeks else AVG_DAYS_PER_MONTH))

            __blame_lock__.release()  # ...to here.
Exemplo n.º 4
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):
				content = Blame.get_content(j)
				(comments, is_inside_comment) = comment.handle_comment_block(is_inside_comment, self.extension, content)

				if Blame.is_prior(j) and interval.get_since():
					continue

				email = Blame.get_author_email(j)
				author = self.changes.get_latest_author_by_email(email)
				__blame_lock__.acquire() # Global lock used to protect calls from here...

				if not filtering.set_filtered(author, "author") and not filtering.set_filtered(email, "email"):
					if self.blames.get((author, self.filename), None) == None:
						self.blames[(author, self.filename)] = BlameEntry()

					self.blames[(author, self.filename)].comments += comments
					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
Exemplo n.º 5
0
	def __handle_blamechunk_content__(self, content):
		author = None
		(comments, self.is_inside_comment) = comment.handle_comment_block(self.is_inside_comment, self.extension, content)

		if self.blamechunk_is_prior and interval.get_since():
			return
		try:
			author = self.changes.get_latest_author_by_email(self.blamechunk_email)
		except KeyError:
			return

		if not filtering.set_filtered(author, "author") and not \
		       filtering.set_filtered(self.blamechunk_email, "email") and not \
		       filtering.set_filtered(self.blamechunk_revision, "revision"):

			__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()

			self.blames[(author, self.filename)].comments += comments
			self.blames[(author, self.filename)].rows += 1

			if (self.blamechunk_time - self.changes.first_commit_date).days > 0:
				self.blames[(author, self.filename)].skew += ((self.changes.last_commit_date - self.blamechunk_time).days /
				                                             (7.0 if self.useweeks else AVG_DAYS_PER_MONTH))

			__blame_lock__.release() # ...to here.
Exemplo n.º 6
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_mail = Blame.get_author_mail(j)
                content = Blame.get_content(j)
                __blame_lock__.acquire(
                )  # Global lock used to protect calls from here...

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

                (comments, is_inside_comment) = comment.handle_comment_block(
                    is_inside_comment, self.extension, content)
                self.blames[(author_mail, self.filename)].comments += comments
                self.blames[(author_mail, self.filename)].rows += 1
                __blame_lock__.release()  # ...to here.

        git_blame_r.close()
        __thread_lock__.release(
        )  # Lock controlling the number of threads running
Exemplo n.º 7
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
Exemplo n.º 8
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
Exemplo n.º 9
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
Exemplo n.º 10
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
Exemplo n.º 11
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):
                content = Blame.get_content(j)
                (comments, is_inside_comment) = comment.handle_comment_block(
                    is_inside_comment, self.extension, content)

                if Blame.is_prior(j) and interval.get_since():
                    continue

                email = Blame.get_author_email(j)
                try:
                    author = self.changes.get_latest_author_by_email(email)
                except KeyError:
                    continue

                __blame_lock__.acquire(
                )  # Global lock used to protect calls from here...

                if not filtering.set_filtered(
                        author, "author") and not filtering.set_filtered(
                            email, "email"):
                    if self.blames.get((author, self.filename), None) == None:
                        self.blames[(author, self.filename)] = BlameEntry()

                    self.blames[(author, self.filename)].comments += comments
                    self.blames[(author, self.filename)].rows += 1

                    time = Blame.get_time(j)
                    time = datetime.date(int(time[0:4]), int(time[5:7]),
                                         int(time[8:10]))

                    if (time - self.changes.first_commit_date).days > 0:
                        self.blames[(author, self.filename)].skew += (
                            (self.changes.last_commit_date - time).days /
                            (7.0 if self.useweeks else AVG_DAYS_PER_MONTH))

                __blame_lock__.release()  # ...to here.

        git_blame_r.close()
        __thread_lock__.release(
        )  # Lock controlling the number of threads running
Exemplo n.º 12
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_mail = Blame.get_author_mail(j)
				content = Blame.get_content(j)
				__blame_lock__.acquire() # Global lock used to protect calls from here...

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

				(comments, is_inside_comment) = comment.handle_comment_block(is_inside_comment, self.extension, content)
				self.blames[(author_mail, self.filename)].comments += comments
				self.blames[(author_mail, self.filename)].rows += 1
				__blame_lock__.release() # ...to here.

		git_blame_r.close()
		__thread_lock__.release() # Lock controlling the number of threads running
Exemplo n.º 13
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):
                content = Blame.get_content(j)
                (comments, is_inside_comment) = comment.handle_comment_block(is_inside_comment, self.extension, content)

                if Blame.is_prior(j) and interval.get_since():
                    continue

                email = Blame.get_author_email(j)
                try:
                    author = self.changes.get_latest_author_by_email(email)
                except KeyError:
                    continue

                __blame_lock__.acquire()  # Global lock used to protect calls from here...

                if not filtering.set_filtered(author, "author") and not filtering.set_filtered(email, "email"):
                    if self.blames.get((author, self.filename), None) == None:
                        self.blames[(author, self.filename)] = BlameEntry()

                    self.blames[(author, self.filename)].comments += comments
                    self.blames[(author, self.filename)].rows += 1

                    time = Blame.get_time(j)
                    time = datetime.date(int(time[0:4]), int(time[5:7]), int(time[8:10]))

                    if (time - self.changes.first_commit_date).days > 0:
                        self.blames[(author, self.filename)].skew += (self.changes.last_commit_date - time).days / (
                            7.0 if self.useweeks else AVG_DAYS_PER_MONTH
                        )

                __blame_lock__.release()  # ...to here.

        git_blame_r.close()
        __thread_lock__.release()  # Lock controlling the number of threads running
Exemplo n.º 14
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):
                content = Blame.get_content(j)
                (comments, is_inside_comment) = comment.handle_comment_block(
                    is_inside_comment, self.extension, content)

                if Blame.is_prior(j) and interval.get_since():
                    continue

                email = Blame.get_author_email(j)
                author = self.changes.get_latest_author_by_email(email)
                __blame_lock__.acquire(
                )  # Global lock used to protect calls from here...

                if not filtering.set_filtered(
                        author, "author") and not filtering.set_filtered(
                            email, "email"):
                    if self.blames.get((author, self.filename), None) == None:
                        self.blames[(author, self.filename)] = BlameEntry()

                    self.blames[(author, self.filename)].comments += comments
                    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