An open API service indexing awesome lists of open source software.

https://github.com/xing/jungle

Complexity metrics for Cocoapods and SwiftPM
https://github.com/xing/jungle

cocoapods complexity dependency spm swift swiftpm

Last synced: 6 months ago
JSON representation

Complexity metrics for Cocoapods and SwiftPM

Awesome Lists containing this project

README

          

# Jungle

[![Swift](https://github.com/xing/jungle/actions/workflows/swift.yml/badge.svg)](https://github.com/xing/jungle/actions/workflows/swift.yml)

A Swift CLI tool that generates complexity metrics information from a Cocoapods Xcode project or a SwiftPM package. Currently, thatยดs what you can do:
- Dependency graph (dot format)
- Cyclomatic complexity evaluation
- Number of dependant modules
- Compare stats between different branches
- Show stats along the git history
- Show dependant targets

You can read more information about dependency complexity in our Technical article ["How to control your dependencies"](https://tech.xing.com/how-to-control-your-ios-dependencies-7690cc7b1c40).

## Table of contents

- [Installation](#installation)
* [Mint](#mint)
* [Manual](#manual)
- [Usage](#usage)
* [Fetch Historic Complexities](#fetch-historic-complexities)
* [Compare Complexity Graphs](#compare-complexity-graphs)
* [Count Module Dependencies](#count-module-dependencies)
* [Visualize Complexity Graphs](#visualize-complexity-graphs)
+ [Some tips](#some-tips)
- [Contributing](#contributing)
* [Contributor License Agreement](#contributor-license-agreement)

## Installation

### Mint

```bash
mint install xing/jungle
mint run jungle help
```

### Manual

```bash
git clone https://github.com/xing/jungle
cd jungle
swift build -c release
.build/release/jungle help
```

## Usage

### Fetch Historic Complexities

```shell
OVERVIEW: Displays historic complexity of the dependency graph

USAGE: jungle history [--since ] [--module ] --target [--output-format ] []

ARGUMENTS:
Path to the directory where Podfile.lock is located (default: .)

OPTIONS:
--since Equivalent to git-log --since: Eg: '6 months ago' (default: 6 months ago)
--module The Module to compare. If you specify something, target parameter will be ommited
--target The target in your Podfile or Package.swift file to be used (this can be a Product name in SPM)
--output-format
csv or json (default: csv)
--version Show the version.
-h, --help Show help information.
```

Example:

```shell
jungle history --target App ProjectDirectory/ --since '1 week ago'

2022-08-30T15:12:14+02:00;cdb9d2ce64a;124;21063;Author;commit message
2022-09-02T11:02:12+02:00;4fdf3a157a4;124;21063;Author;commit message
Now;Current;124;21063;;
```

### Compare Complexity Graphs

```shell
OVERVIEW: Compares the current complexity of the dependency graph to others versions in git

USAGE: jungle compare [--to ...] [--module ] --target []

ARGUMENTS:
Path to the directory where Podfile.lock or Package.swift is located (default: .)

OPTIONS:
--to The git objects to compare the current graph to. Eg: - 'main', 'my_branch', 'some_commit_hash'. (default: HEAD, main, master)
--module The Module to compare. If you specify something, target parameter will be ommited
--target The target in your Podfile or Package.swift file to be used (this can be a Product name in SPM)
--version Show the version.
-h, --help Show help information.
```

Example:

```shell

jungle compare --target App ProjectDirectory/ --to main
[
{
"modules" : 124,
"complexity" : 20063,
"name" : "Current",
"moduleCount" : 124
},
{
"modules" : 124,
"complexity" : 21063,
"name" : "main",
"moduleCount" : 124
}
]
```

### Count Module Dependencies

```shell
OVERVIEW: Outputs a sorted list of modules dependencies count of your project

USAGE: jungle modules --target []

ARGUMENTS:
Path to the directory where Podfile.lock or Package.swift is located (default: .)

OPTIONS:
--target The target in your Podfile or Package.swift file to be used (this can be a Product name in SPM)
--version Show the version.
-h, --help Show help information.

```

Example:

```shell
jungle modules --target jungle

4 - PodExtractor
3 - SPMExtractor
2 - DependencyGraph
0 - Shell
0 - ArgumentParser

```

### Get dependant modules

```shell
OVERVIEW: Outputs a sorted list of targets that depends on the specified one in target

USAGE: jungle dependant --target [--show-only-tests] []

ARGUMENTS:
Path to the directory where Podfile.lock or Package.swift is located (default: .)

OPTIONS:
--target The target in your Podfile or Package.swift file to be used (this can be a Product name in SPM)
--show-only-tests Show only Test targets
--version Show the version.
-h, --help Show help information.

```

Example:

```shell
jungle dependant --target SamplePackage $HOME/Desktop/SamplePackage

Library, LibraryTests, SamplePackageTests

### Visualize Complexity Graphs

```shell
OVERVIEW: Outputs the dependency graph in DOT format

USAGE: jungle graph [--of ] [--module ] --target [--use-multiedge] [--show-externals] []

ARGUMENTS:
Path to the directory where Podfile.lock or Package.swift is located (default: .)

OPTIONS:
--of A git object representing the version to draw the graph for. Eg: - 'main', 'my_branch', 'some_commit_hash'.
--module The Module to compare. If you specify something, target parameter will be ommited
--target The target in your Podfile or Package.swift file to be used (this can be a Product name in SPM)
--use-multiedge Use multi-edge or unique-edge configuration
--show-externals Show Externals modules dependencies
--version Show the version.
-h, --help Show help information.

```

Outputs DOT format which can be viewed using http://viz-js.com

#### Some tips

๐Ÿ’ก Copy CSV (to paste in a spreadsheet) or DOT (to paste at http://viz-js.com) to the clipboard using `pbcopy`

```shell
jungle graph --target App ProjectDirectory/ | pbcopy
jungle history --target App ProjectDirectory/ | pbcopy
```

๐Ÿ’ก Use Graphviz tool to generate your own graphs

```shell
brew install graphviz
jungle graph --target App ProjectDirectory/ | dot -Tpng -o graph.png && open graph.png
```

## Contributing

๐ŸŽ Bug reports and pull requests for new features/ideas are most welcome!

๐Ÿ‘ท๐Ÿผ We are looking forward to your pull request, we'd love to help!

You can help by doing any of the following:

- Reviewing pull requests
- Bringing ideas for new features
- Answering questions on issues
- Improving documentation

This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant code](http://contributor-covenant.org/) of conduct.

### Contributor License Agreement

Contributions to this project must be accompanied by a Contributor License
Agreement. You (or your employer) retain the copyright to your contribution,
this simply gives us permission to use and redistribute your contributions as
part of the project. Find the agreement [here][XING CLA] and head over to [the
contributors page][contributors] and find a XING employee to contact for further
instructions.

You generally only need to submit a CLA once, so if you've already submitted one
(even if it was for a different project), you probably don't need to do it
again.

[XING CLA]: docs/XING_CLAv2.md
[contributors]: https://github.com/xing/jungle/graphs/contributors