Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luhring/funky
A Go (golang) linter that finds mutations.
https://github.com/luhring/funky
ast functional-programming golang linter mutations
Last synced: 3 days ago
JSON representation
A Go (golang) linter that finds mutations.
- Host: GitHub
- URL: https://github.com/luhring/funky
- Owner: luhring
- License: mit
- Created: 2021-08-08T11:19:12.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-21T12:57:58.000Z (about 3 years ago)
- Last Synced: 2024-06-20T14:27:00.276Z (5 months ago)
- Topics: ast, functional-programming, golang, linter, mutations
- Language: Go
- Homepage:
- Size: 39.1 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# funky 🎸
A Go (golang) linter that finds mutations.
## Installation
```
go install github.com/luhring/funky/cmd/funky@main
```## Usage
```
funky ./directory-with-go-files
```(**Note:** Funky doesn't yet analyze directories _recursively_. 😳)
### Example output
```
add.go:134:3: mutation: "destfi" was assigned a new value: nil
add.go:155:5: mutation: "d" was assigned a new value: filepath.Join(dest, path.Base(url.Path))
add.go:157:7: mutation: "err" was assigned a new value: addURL(d, src, hostOwner, options.Hasher)
add.go:175:4: mutation: "err" was assigned a new value: os.Stat(esrc)
```## What is a "mutation"?
A mutation is when a variable's value changes. In the Go language, this means an assignment of a value to a variable anywhere **other than** where that variable is declared.
For example, here's some Go code that has a few mutations:
```go
package mainvar x = 1 // Not a mutation. This is where `x` is declared.
func main() {
x = 7 // MUTATION! (... of `x`, which is declared as a package-level variable.)var output string // Not a mutation. This is where `output` is declared, and it's implicitly being assigned the zero-value of the `string` type, which is "".
if someCondition {
output = "new value" // MUTATION!
}print(output)
}
```## The mission: functional programming for Go
Funky's objective is to take the approaches of functional programming and apply them to the Go language.
The first task is to alert developers to the presence of **mutations**.
Mutations introduce complexity in code. Because of this, they make code more likely to introduce bugs and more difficult to comprehend. Funky alerts you to the mutations in your code so you can spot opportunities for making your code less complex and more predictable — presumably, by adjusting your implementation to avoid mutations.
### "...but Go isn't a functional programming language"
That's true (to some extent). But more developers are realizing the benefits of applying coding practices _taken from the functional paradigm_ to more languages than just the esoteric FP languages.
## Roadmap
- [ ] support for recursive directory analysis (e.g. `./...`)
- [ ] CI pipeline
- [ ] release pipeline
- [ ] **feature:** avoiding mutations
- [x] mutation detection
- [ ] failure on mutation detection
- [ ] configurable exceptions to mutation detection-based failing
- [ ] **feature:** avoiding side effects
- [ ] side effect detection
- [ ] failure on side effect detection
- [ ] configurable exceptions to side effect detection-based failing