prasadtalasila/IRCLogParser

View on GitHub
lib/analysis/user.py

Summary

Maintainability
F
4 days
Test Coverage

Function keywords has a Cognitive Complexity of 93 (exceeds 5 allowed). Consider refactoring.
Open

def keywords(log_dict, nicks, nick_same_list):
    """
    Returns keywods for all users

    Args:
Severity: Minor
Found in lib/analysis/user.py - About 1 day to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function nick_change_graph has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

def nick_change_graph(log_dict, DAY_BY_DAY_ANALYSIS=False):

    """ creates a graph which tracks the nick changes of the users
    where each edge has a time stamp denoting the time 
    at which the nick was changed by the user
Severity: Minor
Found in lib/analysis/user.py - About 5 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File user.py has 316 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import networkx as nx
import re
import sys
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.feature_extraction import text 
Severity: Minor
Found in lib/analysis/user.py - About 3 hrs to fix

Function keywords_clusters has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def keywords_clusters(log_dict, nicks, nick_same_list, output_directory, out_file_name):
    """ 
        Uses `keywords` to form clusters of words post TF IDF (optional).

    Args:   
Severity: Minor
Found in lib/analysis/user.py - About 3 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function top_keywords_for_nick has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

def top_keywords_for_nick(user_keyword_freq_dict, nick, threshold, min_words_spoken):
    """
    outputs top keywords for a particular nick

    Args:
Severity: Minor
Found in lib/analysis/user.py - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Avoid deeply nested control flow statements.
Open

                        while earlier_line_no >= 0: #to find the line just before "=="" so as to find time of Nick Change
                            earlier_line_no = earlier_line_no - 1
                            if(day_log[earlier_line_no][0] != '='):
                                year, month, day = util.get_year_month_day(day_content)
                                today_nick_change_graph, aggregate_nick_change_graph = util.build_graphs(nick1, nick2, day_log[earlier_line_no][1:6], year, month, day, today_nick_change_graph, aggregate_nick_change_graph)
Severity: Major
Found in lib/analysis/user.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                    if fr:
                        user_words_dict.append({'sender':nick_sender, 'words':word_list_lemmatized }) 

Severity: Major
Found in lib/analysis/user.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        for ind in order_centroids[i, :config.SHOW_N_WORDS_PER_CLUSTER]:
                                outfile.write(' %s\n' % terms[ind])
                        outfile.write("\n")
Severity: Major
Found in lib/analysis/user.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                    if correctedNickReciever in message:
                        message.remove(correctedNickReciever)

Severity: Major
Found in lib/analysis/user.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                    for dic in user_words_dict:
                        if dic['sender'] == nick_sender:
                                dic['words'].extend(word_list_lemmatized)
                                fr = 0
                    if fr:
Severity: Major
Found in lib/analysis/user.py - About 45 mins to fix

Function get_nick_receiver has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def get_nick_receiver(nick_receiver, rec, nick_to_compare, nick_name, nicks, nick_same_list):
Severity: Minor
Found in lib/analysis/user.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if(earlier_line_no == -1):
                            today_nick_change_graph.add_edge(nick1, nick2, weight=rem_time)
                            aggregate_nick_change_graph.add_edge(nick1, nick2, weight = rem_time)
                
Severity: Major
Found in lib/analysis/user.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                    for nick_name in nicks:
                        rec_list = [e.strip() for e in line.split(':')] #receiver list splited about :
                        rec_list = util.rec_list_splice(rec_list)

                        if not rec_list[1]: #index 0 will contain time 14:02
Severity: Major
Found in lib/analysis/user.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                    for word in word_list_temp:
                        word = word.lower()
                        word_list.append(word.replace("'",""))
                    word_list_lemmatized = []
Severity: Major
Found in lib/analysis/user.py - About 45 mins to fix

Function keywords_clusters has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def keywords_clusters(log_dict, nicks, nick_same_list, output_directory, out_file_name):
Severity: Minor
Found in lib/analysis/user.py - About 35 mins to fix

Error: Missing parentheses in call to 'print'. Did you mean print(print "No word's normalised score crosses the value of", threshold)? (<unknown>, line 121)</unknown>
Open

                print "No word's normalised score crosses the value of", threshold
Severity: Minor
Found in lib/analysis/user.py by radon

We encountered an error attempting to analyze this line.

There are no issues that match your filters.

Category
Status