An Intellij/Android Studio plugin to help visualise side effects in your code.

Overview

Deprecated

This project is no longer maintained. No new issues or pull requests will be accepted. You can still use the source or fork the project to suit your needs.

Here Be Dragons

Here be dragons is an Intellij/Android Studio plugin that let's you annotate your impure Java methods with the @SideEffect annotation and shows a little dragon icon in the gutter when you call them.

How the plugin works

Why would I want to do this?

When writing functional style code, isolating impure and pure functions becomes very important. This helps you visually identify which methods are impure when a bunch of methods are being called in a code block.

For a beginner friendly introduction to functional programming in Android, please checkout out my blog series.

Installation

Install the plugin

Download the plugin jar and select "Install Plugin From Disk" in IntelliJ's plugin preferences.

Add the annotation library

Add the jcenter repository to your gradle build file if it's not already present:

repositories {
    jcenter()
}

Next, add the lib containing the @SideEffect annotation as a dependency:

dependencies {
    compile 'com.anupcowkur:here-be-dragons-annotation:1.0.1'
}

Usage

Simpy add the @SideEffect annotation to any method you want like this:

import com.anupcowkur.herebedragons.SideEffect;

public class Test {
    @SideEffect
    public void foo() {
        // do some impure things
    }
}

And when you call the method anywhere, you'll see the dragon icon show up in the IDE gutter.

License

This project is licensed under the MIT License

Comments
  • Annotations for indicating a parameter is modified by the function

    Annotations for indicating a parameter is modified by the function

    Let me start by saying, the name you've come up with for this library is awesome, I'm very tempted to steal it to make my own variation. That being said, I figured I'd run my proposal by you before performing grand theft (please understand this is meant as a compliment, not a threat).

    I'd like to be able to annotate the parameters on methods if the parameters get side effected. For example:

    /**
     * Allow us to annotate that collection passed has elements added/removed/sorted/ect...
     * within the method.
     */
    int doActions(@SideEffectModifies(type = COLLECTION) final Set<Something> somethings) {
        somethings.add(anotherSomething());
        return somethings.size();
    }
    
    /**
     * Allow us to annotate that collection elements get modified when passed to the method.
     */
    int doActions(@SideEffectModifies(type = ELEMENTS) final Set<Something> somethings) {
        something.forEach(something -> something.setIt("it"));
        return somethings.size();
    }
    
    /**
     * Allow us to annotate that both kinds of side effecting happens.
     */
    int doActions(@SideEffectModifies(type = BOTH) final Set<Something> somethings) {
        somethings.add(anotherSomething());
        something.forEach(something -> something.setIt("it"));
        return somethings.size();
    }
    

    My particular use case is that I'm refactoring a large swath of code. I'd like myself and other developers to leave hints to each other that we have discovered this kind of side effecting behaviour. The goal is, while you might not be able to do the refactor to fix the problem at the time, you've figured out this is what is going on.

    opened by JLLeitschuh 5
  • Ability to mark all methods inside a type with SideEffect

    Ability to mark all methods inside a type with SideEffect

    For instance, all methods in a Retrofit interface instance carry side-effects. Instead of marking every single method with a @SideEffect (which also clutters the method definitions in the class), I prefer marking the entire type instead.

    This would also require another annotation to mark exclusions inside a class. Maybe another annotation named @Pure.

    enhancement help wanted 
    opened by rjoncontract 2
  • Provide Kotlin support

    Provide Kotlin support

    This is a neat little plugin, I can see it come in very helpful. I mainly develop in Kotlin though, so it would be great if I could also use it there - right now, I can annotate Kotlin code and it will show the dragon when called from Java code, but no dragons are shown in Kotlin code.

    enhancement help wanted 
    opened by roschlau 2
  • Watch for global variable mutation

    Watch for global variable mutation

    Would it be possible to detect side effects in addition to the annotation? Watching for interaction with anything with a greater scope than the method (such as a field). I would be much more likely to use this if I didn't have to remember to add the annotation to every method with a side effect.

    enhancement help wanted 
    opened by vgonda 1
  • Cannot build with java 1.7

    Cannot build with java 1.7

    My main android module build file have set java version = 1.7

      compileOptions {
        encoding "UTF-8"
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
      }
    

    Here is the error message when ran the app.

    Error:Error converting bytecode to dex:
    Cause: Dex cannot parse version 52 byte code.
    This is caused by library dependencies that have been compiled using Java 8 or above.
    If you are using the 'java' gradle plugin in a library submodule add 
    targetCompatibility = '1.7'
    sourceCompatibility = '1.7'
    to that submodule's build.gradle file.
    ...while parsing com/anupcowkur/herebedragons/SideEffect.class
    
    bug 
    opened by johnwatsondev 0
  • Take advantage of the Releases mechanism on GitHub

    Take advantage of the Releases mechanism on GitHub

    If one creates a tag of each release, from that point forward GitHub provides a way of attaching arbitrary release artifacts to that tag, moving the burden of hosting the artifacts onto GitHub and out of the repo itself.

    One may do that manually, or GitHub also offers an API to create a release and then upload assets into it. One can create an api key suitable for housing in Travis or Circle or whatever, but the scope needs to be repo as I don't believe there is a scope specifically to "create a release."

    GitHub also has helpful content which describes the overall picture

    enhancement 
    opened by mdaniel 0
  • Very minor typo in ReadMe

    Very minor typo in ReadMe

    In this line

    This helsp you visually identify which methods are impure when a bunch of methods are being called in a code block

    It should be helps.

    Please correct it.

    .

    opened by vjs3 0
Releases(v1.0.1)
Owner
Anup Cowkur
Anup Cowkur
IntelliJ Idea Astor Plugin is a plugin that integrates Astor in Intellij Idea

IntelliJ Idea Astor Plugin IntelliJ Idea Astor Plugin is a plugin that integrates Astor in Intellij Idea. It communicates with a local/remote program

null 4 Aug 28, 2021
Intellij-platform-plugin-template - IntelliJ Platform Plugin Template

IntelliJ Platform Plugin Template TL;DR: Click the Use this template button and

null 0 Jan 1, 2022
Kirill Rakhman 4 Sep 15, 2022
A plugin for Android Studio and Intellij IDEA that speeds up your day to day android development.

ADB Idea A plugin for Android Studio and Intellij IDEA that speeds up your day to day android development. The following commands are provided: Uninst

Philippe Breault 2k Dec 28, 2022
IntelliJ / Android Studio plugin for Android Holo Colors

This project is not maintained anymore. Holo Colors doesn't make sense since the introduction of Material Design and the ability to set the primary co

Jérôme Van Der Linden 644 Nov 10, 2022
Android Studio & IntelliJ Plugin for sort xml by name="xxx".

AndroidXmlSorter Android Studio & IntelliJ Plugin for sort xml by name="xxx". Options Insert space between difference prefix ('Snake Case', 'Camel Cas

Kaoru Tsutsumishita 102 Nov 29, 2022
eventbus-intellij-plugin 3.8 0.0 L1 Java Plugin to navigate between events posted by EventBus.

eventbus-intellij-plugin Plugin to navigate between events posted by EventBus. Post to onEvent and onEvent to Post Install There are two ways. Prefere

Shinnosuke Kugimiya 315 Aug 8, 2022
IntelliJ Plugin for Android Parcelable boilerplate code generation.

IntelliJ/Android Studio Plugin for Android Parcelable boilerplate code generation This tool generates an Android Parcelable implementation based on fi

Michał Charmas 2.1k Dec 27, 2022
IntelliJ plugin that provides a modern and powerful byte code analyzer tool window.

IntelliJ Byte Code Analyzer Plugin This IntelliJ plugin provides a modern and powerful byte code analyzer tool window. Its supports Java, Kotlin, Groo

Marcel Kliemannel 29 Nov 9, 2022
Intellij Idea Plugin that can convert HTML to Compose for Web code.

HtmlToComposeWebConverter Intellij Idea Plugin that can convert HTML to Compose for Web code. Turn this: Into this: Show some ❤️ and star the repo to

Jens Klingenberg 90 Oct 10, 2022
An IntelliJ IDEA plugin is used to inspire you to write code.

InspireWritingPlugin An IntelliJ IDEA plugin is used to inspire you to write code. Whenever you write code that exceeds the specified character, the p

Airsaid 6 Feb 11, 2021
A plugin for Android Studio that speeds up your day-to-day flutter development.

Flutter-Toolkit 中文文档 A plugin for Android Studio that speeds up your day-to-day flutter development. Flutter ToolKit(Flutter Build Runner Helper), to

苏晟 4 Oct 19, 2022
A powerful Gradle Plugin to help you demonstrate your android app

English | 简体中文 sample-gradle-plugin ?? A powerful Gradle Plugin to help you demonstrate your android app. We often write demo applications that contai

Yoo Zhou 12 Nov 5, 2022
This plugin help you to set material design icon to your project.

Android Material Design Icon Generator Plugin This plugin help you to set material design icons to your Android project. Installation Manually Downloa

Yusuke Konishi 2.4k Dec 30, 2022
Dokka plugin to render Mermaid graphics, from your code comments to your Dokka documentation.

Dokka plugin to render Mermaid graphics, from your code comments to your Dokka documentation.

Grégory Lureau 24 Jan 7, 2023
IntelliJ plugin that provides some useful utilities to support the daily work with Gradle.

IntelliJ Gradle Utilities Plugin This IntelliJ plugin provides some useful utilities to support the daily work with Gradle. It's available on the offi

Marcel Kliemannel 6 Jul 29, 2022
IntelliJ-based IDEs Protobuf Language Plugin that provides Protobuf language support.

IntelliJ Protobuf Language Plugin Reference Inspired by protobuf-jetbrains-plugin and intellij-protobuf-editor. Descriptor IntelliJ-based IDEs Protobu

Kanro 72 Dec 7, 2022
Plugin for IntelliJ-based IDEs folding root files in the ProjectView

Foldable ProjectView The Foldable ProjectView is a plugin for the IntelliJ-based IDEs that lets you fold files located in the root of your project. Av

Jakub Chrzanowski 47 Dec 13, 2022
✈️ IDE plugin for the IntelliJ platform which adds GitHub Copilot support. (VERY WIP)

JetBrains Copilot GitHub Copilot support for the IntellIJ Platform. Installation Download the latest release. Select the Install Plugin from Disk opti

Koding 155 Dec 10, 2022