tushartushar / DesigniteJava

Detects smells and computes metrics of Java code
https://www.designite-tools.com/products-dj
Apache License 2.0
172 stars 64 forks source link

Metric for some code smells #79

Closed sac111 closed 2 years ago

sac111 commented 2 years ago

What metrics along with their threshold value have been used to detect below code smells in the tool? 1.Magic number

  1. Feature envy
  2. Complex condition
  3. Empty catch block

Kindly provide the response as I could not find it.

tushartushar commented 2 years ago

A note: not every smells can be detected using metrics; some smells uses heuristics/rules (sometimes combined with metrics)

  1. Magic number

Any number in code except 0 and 1 is a magic number

  1. Feature envy

method calls and field accesses to its present class < method calls and field accesses to another class

  1. Complex condition

Three or more conditions in a conditional (eg if statement) block

  1. Empty catch block

No of statements in the catch block = 0

sac111 commented 2 years ago

Thanks a lot. It means we can not detect these code smells using the datasets while using a machine learning technique.