prasadtalasila/IRCLogParser

View on GitHub

Showing 95 of 95 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

Severity: Major
Found in lib/in_out/parser/scummvm.py and 2 other locations - About 2 hrs to fix
lib/in_out/parser/slack.py on lines 0..35
lib/in_out/parser/ubuntu.py on lines 0..35

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 59.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

Severity: Major
Found in lib/in_out/parser/slack.py and 2 other locations - About 2 hrs to fix
lib/in_out/parser/scummvm.py on lines 0..35
lib/in_out/parser/ubuntu.py on lines 0..35

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 59.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

File vis.py has 276 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import matplotlib as mpl
import matplotlib.pyplot as plt
plt.switch_backend('Agg')
import numpy as np
from scipy.optimize import curve_fit
Severity: Minor
Found in lib/vis.py - About 2 hrs to fix

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

def linux_input(log_directory, channels_requested, starting_date, ending_date):
    """  
        reads the IRC-Logs files in linux environment

    Args:
Severity: Minor
Found in lib/in_out/reader.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

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

Function channel_user_presence_graph_and_csv has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def channel_user_presence_graph_and_csv(nicks, nick_same_list, channels_for_user, nick_channel_dict, nicks_hash, channels_hash):
    """ creates a directed graph for each nick,
    each edge from which points to the IRC Channels that nick has participated in.
    (Nick changes are tracked here and only the initial nick is shown if a user changed his nick)

Severity: Major
Found in lib/analysis/network.py - About 2 hrs to fix

Cyclomatic complexity is too high in function conv_len_conv_refr_time. (9)
Open

def conv_len_conv_refr_time(log_dict, nicks, nick_same_list, rt_cutoff_time, cutoff_percentile):

    """ Calculates the conversation length (CL) that is the length of time for which two users communicate
    i.e. if a message is not replied to within Response Time(RT),
    then it is considered as a part of another conversation.
Severity: Minor
Found in lib/analysis/channel.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

Cyclomatic complexity is too high in function extend_conversation_list. (7)
Open

def extend_conversation_list(nick_sender, nick_receiver, conversation):
    """ A functions that takes the nick_sender and nick_reciver and add them
        the conversation list and increase the weight.
        Args:
            nick_sender : nick of user sending a message
Severity: Minor
Found in lib/util.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

Cyclomatic complexity is too high in function truncate_table. (6)
Open

def truncate_table(table, cutoff_percentile):

    """
    The calculations of conversation characteristics, namely RT, CL and CRT, are
    based on the cutoff values estimated for RT and CL. This generic function takes
Severity: Minor
Found in lib/analysis/channel.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

Function degree_analysis_on_graph has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def degree_analysis_on_graph(nx_graph, date=None, directed = True):
    """
    perform degree analysis of input graph object
    
    Arguments:
Severity: Minor
Found in lib/analysis/network.py - About 1 hr 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 identify_hubs_and_experts has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def identify_hubs_and_experts(log_dict, nicks, nick_same_list):
    """
        uses message_number graph to identify hubs and experts in the network

    Args:
Severity: Minor
Found in lib/analysis/network.py - About 1 hr 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

Error: Missing parentheses in call to 'print'. Did you mean print(int "[Unexpected Value] of Arg", value_number, " @", fileName, "| EXPECTED_RANGE:", )? (<unknown>, line 45)</unknown>
Open

    print "[Unexpected Value] of Arg", value_number, " @", fileName, "| EXPECTED_RANGE:", \
Severity: Minor
Found in lib/validate.py by radon

We encountered an error attempting to analyze this line.

Error: Missing parentheses in call to 'print'. Did you mean print(print "code-length:", codelength)? (<unknown>, line 26)</unknown>
Open

        print "code-length:", codelength
Severity: Minor
Found in lib/analysis/community.py by radon

We encountered an error attempting to analyze this line.

Error: invalid syntax (<unknown>, line 84)</unknown>
Open

                    print "Analysis on", (str(day_content["auxiliary_data"]["day"]) + "-" + str(day_content["auxiliary_data"]["month"])), channel_name
Severity: Minor
Found in lib/nickTracker.py by radon

We encountered an error attempting to analyze this line.

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.

Error: Missing parentheses in call to 'print'. Did you mean print(int "\nBuilding graph object with EDGE WEIGHT THRESHOLD:", config.THRESHOLD_MESSAGE_NUMBER_GRAPH)? (<unknown>, line 104)</unknown>
Open

    print "\nBuilding graph object with EDGE WEIGHT THRESHOLD:", config.THRESHOLD_MESSAGE_NUMBER_GRAPH
Severity: Minor
Found in lib/analysis/network.py by radon

We encountered an error attempting to analyze this line.

Error: invalid syntax (<unknown>, line 52)</unknown>
Open

        print "Generating", (output_file_name + ".svg")
Severity: Minor
Found in lib/in_out/saver.py by radon

We encountered an error attempting to analyze this line.

Error: Missing parentheses in call to 'print'. Did you mean print(print "[Error | io/linuxInput] Channel " + work_path + channel + ".txt doesn't exist")? (<unknown>, line 40)</unknown>
Open

                print "[Error | io/linuxInput] Channel " + work_path + channel + ".txt doesn't exist"
Severity: Minor
Found in lib/in_out/reader.py by radon

We encountered an error attempting to analyze this line.

Error: Missing parentheses in call to 'print'. Did you mean print(print "ERROR generate_probability_distribution")? (<unknown>, line 55)</unknown>
Open

        print "ERROR generate_probability_distribution"
Severity: Minor
Found in lib/vis.py by radon

We encountered an error attempting to analyze this line.

Similar blocks of code found in 3 locations. Consider refactoring.
Open

            total_degree_fit_parameters[dt.month-1] = vis.generate_log_plots(degree_anal_message_number["total_degree"]["raw_for_vis"], output_directory, channel_name_iter[0])
Severity: Major
Found in lib/validate.py and 2 other locations - About 1 hr to fix
lib/validate.py on lines 83..83
lib/validate.py on lines 84..84

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 45.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Severity
Category
Status
Source
Language