Home

Awesome

License Version Language Platform Cohesion

<p align="center"> <img src="Assets/logo-long.svg" title="CoherentSwift"> </p> <p align="center">Coherent Swift is a command line tool written in Swift that measures cohesion in your Swift codebase .</p>

Features

What is Cohesion?

In computer programming, cohesion refers to the degree to which the elements of a module belong together. Thus, cohesion measures the strength of relationship between pieces of functionality within a given module. For example, in highly cohesive systems functionality is strongly related.

When cohesion is high, it means that the methods and variables of the class are co-dependent and hang together as a logical whole.

Some of the advantages of high cohesion, also by Wikipedia:

coherent-swift is inspired by cohesion.

Installation

Homebrew (recommended)

brew install arthurpalves/m/coherent-swift

Mint

mint install arthurpalves/coherent-swift

Make

git clone https://github.com/arthurpalves/coherent-swift.git
cd coherent-swift
make install

Swift Package Manager

Use as CLI

git clone https://github.com/arthurpalves/coherent-swift.git
cd coherent-swift
swift run coherent-swift

Usage

Usage: coherent-swift <command> [options]

A command-line tool to analyze and report Swift code cohesion

Commands:
  init            Generate specs (.yml) file
  report          Generate a report on Swift code cohesion
  help            Prints help information
  version         Prints the current version of this app

Specs | Configuration

Before running the report command you must first have a spec/configuration file. This is a YAML file containing the basic configuration for coherent-swift.

coherent-swift init

This will generate the file coherent-swift.yml in your working directory. See the specs template

NOTE: By default, coherent-swift expects to find the configuration above in ./coherent-swift.yml, if you do have this file elsewhere or with a different name, please specify it's path by using the parameter -s | --spec.

Scan and report

Usage: coherent-swift report [options]

Generate a report on Swift code cohesion

Options:
  -d, --diffs           Only scan modified files
  -h, --help            Show help information
  -s, --spec <value>    Use a yaml configuration file
  -v, --verbose         Log tech details for nerds

Example

coherent-swift report
<p align="center"> <img src="Assets/GIF/report-animated.gif" alt="coherent-swift report" /> </p>
coherent-swift report --verbose
<p align="center"> <img src="Assets/GIF/report-verbose-animated.gif" alt="coherent-swift report --verbose" /> </p>

Thanks

License

coherent-swift is released under the MIT license. See LICENSE for more information.