Code metrics analyzer for Swift projects.
Project description
swift-code-metrics
Code metrics analyzer for Swift projects.
Introduction
The goal of this software is to provide an insight of the architectural state of a software written in Swift
that consists in several modules.
Inspired by the book of Robert C. Martin, Clean Architecture, the software will scan the project to identify the different components in order to assess several common code metrics in the software industry:
- the overall number of concrete classes and interfaces
- the instability and abstractness of the framework
- the distance from the main sequence
- LOC (Lines Of Code)
- NOC (Numbers Of Comments)
- POC (Percentage Of Comments)
- NOM (Number of Methods)
- Number of concretes (Number of classes and structs)
- NOT (Number Of Tests)
- NOI (Number Of Imports)
- Frameworks dependency graph (number of internal and external dependencies)
Requirements
This is a Python 3 script that depends on matplotlib, adjustText, pyfunctional and pygraphviz.
This latest package depends on the Graphviz binary that must be installed.
Usage
The package is available on pip
with pip3 install swift-code-metrics
.
The syntax is:
swift-code-metrics --source <path-to-swift-project> --artifacts <output-directory> --exclude <excluded-folders> --tests-paths <test-paths> --generate-graphs
--source
is the path to the folder that contains the main Xcode project or Workspace--artifacts
path to the folder that will contain the generatedoutput.json
report--excluded
(optional) space separated list of path substrings to exclude from analysis (e.g.Tests
will ignore all files/folders that containTests
)--tests-paths
(default:Test Tests
) space separated list of path substrings matching test classes--generate-graphs
(optional) if passed, it will generate the graphs related to the analysis and save them in the artifacts folder
Documentation
Please follow the guide with a practical example to get started.
Current limitations
-
This tool is designed for medium/large codebases composed by different frameworks. The script will scan the directory and it will identify the frameworks by the name of the 'root' folder, so it's strictly dependent on the file hierarchy (unless a project path override file is specified)
-
Libraries built with
spm
are not supported. -
The framework name is inferred using the directory structure. If the file is in the root dir, the
default_framework_name
will be used. No inspection of the xcodeproj will be made. -
The list of methods currently doesn't support computed vars
-
Inline comments in code (such as
struct Data: {} //dummy data
) are currently not supported -
Only
XCTest
test frameworks are currently supported
TODOs
- Code improvements
- Other (open to suggestions)
Contact
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for swift_code_metrics-1.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42a52b62628cc106491b6d10532e9888f14fd93075328d1232dbbd215584583c |
|
MD5 | a388a06924f53fa414333d4fdd0f97d5 |
|
BLAKE2b-256 | 2592fbf3a75a3413bc551dcc9b034d7a5c664e69009f439a9cf6da9c97d3f837 |