Skip to content

A static analysis tool engineered to automatically identify, and re-document software systems written in C++, C#, and/or Java with method and class stereotypes.

License

Notifications You must be signed in to change notification settings

srcML/stereocode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛠 Stereocode 1.0

💡 What does it do?

Stereocode classifies methods and classes based on their stereotypes.

Class and method stereotypes are defined in three papers presented at the IEEE International Conference on Software Maintenance (ICSM) in 2006, 2009, and 2010 by Dragan, Collard, and Maletic.

Stereocode takes a srcML archive as input, performs static analysis, and annotates each function and class tag in the XML input with an attribute indicating the detected stereotype. For example:

<class st:stereotype="entity"> ... </class>
<function st:stereotype="get"> ... </function>

This output can be used for further processing or analysis. For instance, the stereotype information can be embedded as documentation in the source code (using comments, Doxygen, Javadoc, etc.).

🔧 Installation and Build

  1. Prerequisites
  1. Clone or download this repository.

  2. Build using cmake:

cmake CMakeLists.txt -B build_path
cd build_path
make

Stereocode is compatible with srcML v1.0, but it might not work as intended in certain cases as it is supported in Stereocode using a workaround.

On MAC OS, if you get an error related to "dyld library not loaded", then you need to export the path of libsrcml.dylib as follows:

export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH 

Or add it to the shell configuration .zshrc or .bash_profile file to make it permanent.

🚀 Usage

Stereocode is a command-line tool. It can process individual source files or entire systems written in C++, Java, and/or C#.

Demo:

# This line converts the PowerShell system to the srcML format
srcml PowerShell.zip -o PowerShell.xml

# Saves the output to PowerShell-output.xml
./stereocode PowerShell.xml -o PowerShell-output.xml

# For more options and help:
./stereocode --help

Note:
Stereocode can stereotype free functions. A free function could a static method/function, a friend function (C++), or simply a function that does not belong to a class (C++) (This is still under development, a taxonomy will be available soon).

📜 Stereocode Options

-o, --output-file: File name of output - srcML archive with stereotypes.

-p, --primitive-file: File name of user supplied primitive types (one per line).

Datatype_1
Datatype_2
...

These data types will be treated as primitive data types such as an int.

-g, --ignore-call-file: File name of user supplied calls to ignore (one per line).

Call_Name_1
Call_Name_2
...

Do not use namespaces, parenthesis, or other special characters. Simply list the call name itself. For example, foo.
These calls are ignored from analysis. However, usage of attributes within these calls (as parameters) are not ignored (considered as accessors to attributes).

-t, --type-modifier-file: File name of user supplied data type modifiers to remove (one per line).

modifier_1
modifier_2
...

These modifiers are removed during analysis to enhance the detection of certain elements such as primitive data types and method return types.

-l, --large-class [int]: Method threshold for the large-class stereotype (default = 21).

-i, --interface: Identify stereotypes for interfaces (C# and Java).

-n, --union: Identify stereotypes for unions (C++).

-m, --enum: Identify stereotypes for enums (Java).

-s, --struct: Identify stereotypes for structs (C# and Java).

-e, --input-overwrite: Overwrite input with stereotype information.

-x, --txt-report: Output optional TXT report file containing stereotype information.

-z, --csv-report: Output optional CSV report file containing stereotype information.

-c, --comment: Annotates stereotypes as a comment before method and class definitetions (/** @stereotype stereotype */).

-v, --verbose: Outputs default primitives, ignored calls, type modifiers, and extra report files.

📓 Developer Notes:

The initial version of this code base was developed by Doleh and documented in his MS Thesis December 2021 at Kent State University. Later, Al-Ramadan updated Stereocode by adding support for additional programming languages (i.e., C# and Java), enabling the stereotyping of complete systems, and incorporating deep static analysis. This work was also documented in MS Thesis May 2024 at Kent State University. Previously, a prototype of Stereocode was developed by Collard and Dragan for Dragan's dissertation in December 2010 at KSU. This prototype was further extended for DySDoc 2018 by Decker and Collard.

Developers of stereocode 1.0:

  • Ali Al-Ramadan - Kent State University
  • Michael L. Collard - University of Akron
  • Michael Decker - Bowling Green State University
  • Zane Doleh - Kent State University
  • Jonathan I. Maletic - Kent State University
  • Nick Weber - Kent State University

About

A static analysis tool engineered to automatically identify, and re-document software systems written in C++, C#, and/or Java with method and class stereotypes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published