kowainik / kowainik/stan

Add 'fromIntegral' inspection as anti-pattern

Open
#377 0 comments 1 reaction 0 assignees View on GitHub
inspection
Dominant language
Haskell
Stars
597
Forks
53
PR merge metrics
No merged PRs in 30d

Description

`fromIntegral` produces unexpected results for almost all types and is partial for `Natural`. We can recommend safer versions of this function.

* `toIntegralSized` from `base`

Additionally, we can add possible solutions for already existing `fromInteger` inspection:

* Suggest `integerToBounded`
* Suggest `integerToNatural`

Contributor guide

Open the contributing guide

Research direction

Start by locating the existing `fromInteger` inspection and its tests, then follow how inspections produce suggestions. Add a `fromIntegral` anti-pattern inspection recommending `toIntegralSized`, and extend the existing recommendations with `integerToBounded` and `integerToNatural`. Done means the diagnostics and their expected suggestions are covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.