https://github.com/cqfn/jpeek
Hosted and command-line calculator of cohesion metrics for Java code
Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
4 of 50 committers (8.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.9%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Hosted and command-line calculator of cohesion metrics for Java code
Basic Info
- Host: GitHub
- Owner: cqfn
- License: mit
- Language: Java
- Default Branch: master
- Homepage: https://i.jpeek.org
- Size: 12.6 MB
Statistics
- Stars: 217
- Watchers: 11
- Forks: 84
- Open Issues: 82
- Releases: 66
Topics
Metadata Files
README.md
jPeek is a static collector of Java code metrics.
Motivation: Class cohesion, for example, is considered as one of most important object-oriented software attributes. There are over 30 different cohesion metrics invented so far, but almost none of them have calculators available. The situation with other metrics is very similar. We want to create such a tool that will make it possible to analyze code quality more or less formally (with hundreds of metrics). Then, we will apply this analysis to different Java libraries with an intent to prove that the ideas from Elegant Objects book series make sense.
How to use?
Load the latest jar-with-dependencies.jar file from
here
and then:
bash
java -jar jpeek-jar-with-dependencies.jar --sources . --target ./jpeek
jPeek will analyze Java files in the current directory.
XML reports will be generated in the ./jpeek directory. Enjoy.
Available CLI options
| Option | Description | |-----------------------------|------------------------------------------------------------------------------------| | `-s, --sourcesYou can also deploy it as a web service to your own platform. Just compile it
with mvn clean package --settings settings.xml and then run, as Procfile suggests.
You will need to have settings.xml with the following data:
xml
<settings>
<profiles>
<profile>
<id>jpeek-heroku</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sentry.dsn>https://...</sentry.dsn>
<dynamo.key>AKIAI..........LNN6A</dynamo.key>
<dynamo.secret>6560KMv5+8Ti....................Qdwob63Z</dynamo.secret>
</properties>
</profile>
</profiles>
</settings>
You will also need these tables in DynamoDB (all indexes must deliver ALL attributes):
jpeek-mistakes:
metric (HASH/String)
version (RANGE/String)
indexes:
mistakes (GSI):
version (HASH/String),
avg (RANGE/Number)
jpeek-results:
artifact (HASH/String)
indexes:
ranks (GSI):
version (HASH/String)
rank (RANGE/Number)
scores (GSI):
version (HASH/String)
score (RANGE/Number)
recent (GSI):
good (HASH/String)
added (RANGE/Number)
Cohesion Metrics
These papers provide a pretty good summary of cohesion metrics:
[izadkhah17]
Habib Izadkhah et al.,
Class Cohesion Metrics for Software Engineering: A Critical Review,
Computer Science Journal of Moldova, vol.25, no.1(73), 2017,
PDF.
[badri08]
Linda Badri et al.,
Revisiting Class Cohesion: An empirical investigation on several systems,
Journal of Object Technology, vol.7, no.6, 2008,
PDF.
Here is a list of metrics we have already implemented (in order or their appearance):
[chidamber94]
Lack of Cohesion in Methods (LCOM).
Shyam Chidamber et al.,
A metrics suite for object oriented design,
IEEE Transactions on Software Engineering, vol.20, no.6, 1994,
PDF.
[bieman95]
Tight Class Cohesion (TCC) and Loose Class Cohesion (LCC).
James M. Bieman et al.,
Cohesion and Reuse in an Object-Oriented System,
Department of Computer Science, Colorado State University, 1995,
PDF.
[hitz95]
Lack of Cohesion in Methods 4 (LCOM4).
Martin Hitz et al.,
Measuring Coupling and Cohesion In Object-Oriented Systems,
Institute of Applied Computer Science and Systems Analysis, University of Vienna, 1995,
PDF.
[sellers96]
Lack of Cohesion in Methods 2-3 (LCOM 2, 3 and 5).
B. Henderson-Sellers et al.,
Coupling and cohesion (towards a valid metrics suite for object-oriented analysis and design),
Object Oriented Systems 3, 1996,
PDF.
[bansiya99]
Cohesion Among Methods of Classes (CAMC).
Jagdish Bansiya et al.,
A class cohesion metric for object-oriented designs,
Journal of Object-Oriented Programming, vol. 11, no. 8, 1999,
PDF.
[etzkorn00]
LOgical Relatedness of Methods (LORM).
L. Etzkorn and H. Delugach,
Towards a semantic metrics suite for object-oriented design,
Technology of Object-Oriented Languages and Systems, 2000. TOOLS 34. Proceedings. 34th International Conference on. IEEE, 2000, pp. 71–80,
PDF
[wasiq01]
Class Connection Metric (CCM).
M. Wasiq
Measuring Class Cohesion in Object-Oriented Systems,
Master Thesis at the King Fahd University of Petroleum & Minerals, 2001,
PDF.
[aman04]
Optimistic Class Cohesion (OCC) and Pessimistic Class Cohesion (PCC).
Hirohisa Aman et al.,
A proposal of class cohesion metrics using sizes of cohesive parts,
Proc. of Fifth Joint Conference on Knowledge-based Software Engineering, 2002,
PDF.
[marcus05]
Conceptual Cohesion of Classes (C3).
A. Marcus and D. Poshyvanyk,
The conceptual cohesion of classes,
21st IEEE International Conference on Software Maintenance (ICSM'05), Budapest, Hungary, 2005, pp. 133-142,
PDF
[counsell06]
Normalized Hamming Distance (NHD).
Steve Counsell et al.,
The interpretation and utility of three cohesion metrics for object-oriented design,
ACM TOSEM, April 2006,
PDF.
[fernandez06]
A Sensitive Metric of Class Cohesion (SCOM).
Luis Fernández et al.,
[A] new metric [...] yielding meaningful values [...] more sensitive than those previously reported,
International Journal "Information Theories & Applications", Volume 13, 2006,
PDF.
[dallal07]
Method-Method through Attributes Cohesion (MMAC).
Jehad Al Dallal,
A Design-Based Cohesion Metric for Object-Oriented Classes,
World Academy of Science, Engineering and Technology International Journal of Computer and Information Engineering Vol:1, No:10, 2007,
PDF.
[liu09]
Maximal Weighted Entropy (MWE).
Y. Liu, D. Poshyvanyk, R. Ferenc, T. Gyim´othy, and N. Chrisochoides,
Modeling class cohesion as mixtures of latent topics,
Software Maintenance, 2009. ICSM 2009. IEEE International Conference on. IEEE, 2009, pp. 233–242,
PDF
[dallal11]
Transitive Lack of Cohesion in Methods (TLCOM).
Jehad Al Dallal,
Transitive-based object-oriented lack-of-cohesion metric,
Department of Information Science, Kuwait University, 2011,
PDF.
How it works?
First, Skeleton parses Java bytecode using Javaassit and ASM, in order to produce
skeleton.xml. This XML document contains information about each class, which
is necessary for the metrics calculations. For example, this simple Java
class:
java
class Book {
private int id;
int getId() {
return this.id;
}
}
Will look like this in the skeleton.xml:
xml
<class id='Book'>
<attributes>
<attribute public='false' static='false' type='I'>id</attribute>
</attributes>
<methods>
<method abstract='false' ctor='true' desc='()I' name='getId' public='true' static='false'>
<return>I</return>
<args/>
</method>
</methods>
</class>
Then, we have a collection of XSL stylesheets, one per each metric. For example,
LCOM.xsl transforms skeleton.xml into LCOM.xml, which may look like this:
xml
<metric>
<title>MMAC</title>
<app>
<class id='InstantiatorProvider' value='1'/>
<class id='InstantiationException' value='0'/>
<class id='AnswersValidator' value='0.0583'/>
<class id='ClassNode' value='0.25'/>
[... skipped ...]
</app>
</metric>
Thus, all calculations happen inside the XSLT files. We decided to implement it this way after a less successful attempt to do it all in Java. It seems that XSL is much more suitable for manipulations with data than Java.
jPeek maven plugin
We are developing a jPeek plugin for Maven, see jPeek Maven plugin project.
Known Limitations
- The java compiler is known to inline constant variables as per JLS 13.1. This affects the results calculated by metrics that take into account access to class attributes if these are
finalconstants. For instance, all LCOM and COM metrics are affected.
How to contribute?
Just fork, make changes, run mvn clean install -Pqulice and submit
a pull request; read this,
if lost.
Contributors
- @yegor256 as Yegor Bugayenko (Blog)
- @alayor as Alonso A. Ortega (Blog)
- @memoyil as Mehmet Yildirim
- @sergey-karazhenets as Sergey Karazhenets
- @llorllale as George Aristy
- @mesut as Mesut Özen
- @serranya as Peter Lamby
- @humb1t as Nikita Puzankov
- @stepanov-dmitry as Dmitry Stepanov
- @GnusinPavel as Gnusin Pavel
- @mohamednizar as Mohamed Nizar
Don't hesitate to add your name to this list in your next pull request.
Owner
- Name: CQFN
- Login: cqfn
- Kind: organization
- Email: team@cqfn.org
- Website: https://www.cqfn.org
- Repositories: 22
- Profile: https://github.com/cqfn
Code Quality Foundation
GitHub Events
Total
- Commit comment event: 4
- Issues event: 4
- Watch event: 10
- Issue comment event: 23
- Push event: 42
- Pull request event: 12
- Fork event: 4
Last Year
- Commit comment event: 4
- Issues event: 4
- Watch event: 10
- Issue comment event: 23
- Push event: 42
- Pull request event: 12
- Fork event: 4
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Yegor Bugayenko | y****6@g****m | 414 |
| Hamdi Douss | d****i@g****m | 83 |
| George Aristy | g****y@g****m | 51 |
| Paulo Lobo | p****o@g****m | 32 |
| Yildirim | M****m@a****m | 27 |
| Ilya Kharlamov | 5****v | 26 |
| d.garus | g****g@g****m | 23 |
| Rok Povsic | r****c@g****m | 18 |
| Kapralov Sergey | s****v@m****u | 17 |
| Raul Estrada | r****a@g****m | 17 |
| mohamednizar | n****c@g****m | 15 |
| Natalia Pozhidaeva | N****a@e****m | 15 |
| Vytautas Žurauskas | z****s@g****m | 14 |
| Dzhovidon Vakhidov | d****v@i****y | 13 |
| Gnusin Pavel | p****n@g****m | 12 |
| Victor Noël | v****l@c****g | 12 |
| felipemoreno | f****o@e****6 | 11 |
| MagDel | p****v@y****u | 10 |
| Andriy Kryvtsun | a****y@a****m | 8 |
| rexim | r****t@g****m | 6 |
| Kaverin Maxim | m****n@e****u | 6 |
| Peter Lamby | p****y@w****e | 5 |
| Alexander Menshikov | s****c@g****m | 4 |
| Vseslav Sekorin | V****n@g****m | 4 |
| Mihai Andronache | a****l@g****m | 3 |
| Nikita Verkhovin | v****3@g****m | 3 |
| Sergey Karazhenets | s****s@m****u | 2 |
| butenkos | s****o@r****u | 2 |
| Nikita | N****v@e****m | 2 |
| George Aristy | g****y@c****o | 2 |
| and 20 more... | ||
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 92
- Total pull requests: 77
- Average time to close issues: 7 months
- Average time to close pull requests: 6 months
- Total issue authors: 20
- Total pull request authors: 21
- Average comments per issue: 10.26
- Average comments per pull request: 4.87
- Merged pull requests: 40
- Bot issues: 0
- Bot pull requests: 8
Past Year
- Issues: 2
- Pull requests: 13
- Average time to close issues: N/A
- Average time to close pull requests: 2 days
- Issue authors: 1
- Pull request authors: 4
- Average comments per issue: 0.0
- Average comments per pull request: 1.46
- Merged pull requests: 8
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- 0pdd (55)
- yegor256 (8)
- User123363 (5)
- victornoel (3)
- starkda (3)
- iMaks99 (3)
- paulodamaso (2)
- ilyakharlamov (1)
- RoRoche (1)
- timur-harin (1)
- vzurauskas (1)
- lokesh-kumar-m (1)
- Mathias83 (1)
- lyriccoder (1)
- fabriciofx (1)
Pull Request Authors
- starkda (9)
- iMaks99 (8)
- pnatashap (8)
- Ivruix (8)
- michaelwelly (8)
- vzurauskas (6)
- dependabot-preview[bot] (5)
- LaithAlebrahim (3)
- dependabot[bot] (3)
- emiliogain (2)
- tanmaysharma2001 (2)
- Jaklbela (2)
- nytakoe1 (2)
- evermake (2)
- nikzor (2)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- com.google.code.findbugs:annotations 3.0.1u2 provided
- com.amazonaws:aws-java-sdk-dynamodb 1.12.276
- com.beust:jcommander 1.82
- com.jcabi.incubator:xembly 0.26.2
- com.jcabi:jcabi-dynamo 0.22.2
- com.jcabi:jcabi-log 0.21.0
- com.jcabi:jcabi-xml 0.23.2
- com.sun.jersey:jersey-client 1.19.4
- io.sentry:sentry 6.3.1
- log4j:log4j 1.2.17
- net.sf.saxon:Saxon-HE 9.8.0-5
- org.cactoos:cactoos 0.52.0
- org.hamcrest:hamcrest-core 2.2
- org.hamcrest:hamcrest-library 2.2
- org.javassist:javassist 3.29.0-GA
- org.ow2.asm:asm 9.3
- org.slf4j:slf4j-log4j12 2.0.0-alpha5
- org.takes:takes 1.22.0
- com.h2database:h2 2.1.214 test
- com.jcabi:jcabi-http 1.20.0 test
- com.jcabi:jcabi-jdbc 0.17.8 test
- com.jcabi:jcabi-matchers 1.5.3 test
- org.hamcrest:hamcrest-core 2.2 test
- org.hamcrest:hamcrest-library 2.2 test
- org.junit.jupiter:junit-jupiter-params 5.9.0 test
- org.llorllale:cactoos-matchers 0.25 test
- commons-io:commons-io