Skip to content

hiimkimchi/Code-Smell-Detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Smell Detector

Detects if a .py file has methods/parameter lists that are too verbose or any duplicated code.

Metrics:

  • A method is too verbose if there are 15 or more lines
  • A parameter list is too verbose if there are 5 or more parameters
  • Duplicated methods are considered duplicates if all the characters' Jaccard similarity scores are 0.75 or above
    • Duplicated methods are able to be refactored (remove one of the duplicates). NOTE: Since the similarity is taken by character and not by AST/semantics, refactoring may cause bugs within the code.

Usage

python3 App.py

Demo

# test.py
def func1(e,f,g):
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    return e,f,g

def func2(a, b, c, d, e, f, g, h):
    return a

def func3(a, b):
    return a * b

def func4(c, d):
    return c * d

Once the file is loaded, the GUI will prompt you to detect the code smells, and present them as so:

GUI

If the user prompts the GUI to refactor duplicate code, the example should look as so:

# test_refactored.py
def func1(e,f,g):
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    print("hi")
    return e,f,g

def func2(a, b, c, d, e, f, g, h):
    return a

def func3(a, b):
    return a * b

This project was built using the following:

About

Detects if a .py file has methods/parameters that are too verbose or any duplicated code

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages