Git Product home page Git Product logo

danger-plugin-lint-report's Introduction

danger-plugin-lint-report

Build Status npm version semantic-release

This plugin reads checkstyle / lint reports and posts issues and violations as inline comments in pull requests.

Screenshot of an issue posted as inline comment in a GitHub pull request:

inline comment

Requirements

The plugin does not execute any linter.

Instead, the plugin will search the file tree for lint reports according to the specified file mask and parse them.

The plugin requires a configuration object with a file mask to search for XML reports.

Supported Reports

If you encounter a format that is missing, feel free to add a pull request or open an issue with a sample report attached.

  • Checkstyle 4.3
  • Checkstyle 8.0
  • Android Lint (Format 5)

Usage

Install:

yarn add danger-plugin-lint-report --dev

At a glance:

// dangerfile.js
import { schedule } from 'danger'

const reporter = require("danger-plugin-lint-report")
schedule(reporter.scan({
    fileMask: "**/reports/lint-results.xml",
    reportSeverity: true,
    requireLineModification: true,
}))

Configuration:

interface CheckstyleConfig {
  /**
   * File mask used to find XML checkstyle reports.
   */
  fileMask: string

  /**
   * If set to true, the severity will be used to switch between the different message formats (message, warn, fail).
   */
  reportSeverity: boolean

  /**
   * If set to true, only issues will be reported that are contained in the current changeset (line comparison).
   * If set to false, all issues that are in modified files will be reported.
   */
  requireLineModification: boolean

  /**
   * Optional: Sets a prefix foreach violation message.
   * This can be useful if there are multiple reports being parsed to make them distinguishable.
   */
  outputPrefix?: string
  
  /**
   * Optional: Override the violation formatter to customize the output message.
   */
   violationFormatter?: ViolationFormatter

  /**
   * Optional: If set to true, it will remove duplicate violations.
   */
  removeDuplicates?: boolean
}

Changelog

See the GitHub release history.

Contributing

See CONTRIBUTING.md.

danger-plugin-lint-report's People

Contributors

arhont375 avatar damian-burke avatar dependabot[bot] avatar jmartinesp avatar locomike avatar mrclrchtr avatar nsugiyam avatar rouby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

danger-plugin-lint-report's Issues

Rename CheckstyleConfig

Should be something else as the plugin is not limited to checkstyle.

Ideas:

  • ReporterConfig
  • LintReportConfig (mirroring the plugin name)

Open to other ideas as well.

Update dependencies

Hi, I would like to know when the following dependencies will be updated:

image

Remove unmaintained optional dependency "esdoc"?

Can the optional dependency on "esdoc" be removed?

This project doesn't seem to use it, as there is no .esdoc.json file anywhere.
Also esdoc is not actively maintained anymore (last commit in 2018) and causes security alerts in downstream projects because of outdated dependencies e.g. marked and nth-check

Implement support for Android Lint format 6

Seems like updating to AGP 7.0.0+ prints lint results in a new format 6 which is currently not supported.

Example report:

<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 7.0.0-alpha08">

    <issue
        id="CoroutinesStaticDispatcher"
        severity="Warning"
        message="Please inject a coroutine scope / context instead of referring to static Dispatchers."
        category="Testing"
        priority="6"
        summary="Do not use static Dispatchers, inject the requires ones"
        explanation="To give us more control over dispatchers and threading, we should inject a Coroutine context if required, &#xA;instead of using the static ones."
        errorLine1="        return withContext(Dispatchers.IO) {"
        errorLine2="                           ~~~~~~~~~~~~~~">
        <location
            file="/Users/damian.burke/StudioProjects/.../src/main/java/com/.../FirebaseDatabase.kt"
            line="21"
            column="28"/>
    </issue>


    <issue
        id="UnusedResources"
        severity="Warning"
        message="The resource `R.bool.isLightMode` appears to be unused"
        category="Performance"
        priority="3"
        summary="Unused resources"
        explanation="Unused resources make applications larger and slow down builds.&#xA;&#xA;The unused resource check can ignore tests. If you want to include resources that are only referenced from tests, consider packaging them in a test source set instead.&#xA;&#xA;You can include test sources in the unused resource check by setting the system property lint.unused-resources.include-tests=true, and to exclude them (usually for performance reasons), use lint.unused-resources.exclude-tests=true."
        errorLine1="    &lt;bool name=&quot;isLightMode&quot;>true&lt;/bool>"
        errorLine2="          ~~~~~~~~~~~~~~~~~~">
        <location
            file="/Users/damian.burke/StudioProjects/.../src/main/res/values/bool.xml"
            line="3"
            column="11"/>
        <location
            file="/Users/damian.burke/StudioProjects/.../src/main/res/values-night/bool.xml"
            line="3"
            column="11"/>
    </issue>
</issues>

Update dependencies

Hi, I would like to know when the following dependencies will be updated:

image

Add optional prefix / identifier to reports

When parsing multiple reports a prefix / identifier can help identify where the current issue originates from.

The identifier would be injected via the CheckstyleConfig.

Setup GitHub Actions

The project needs a couple of GitHub actions to automate some processes:

Each pull request should run:

  • Tests
  • Build

Additionally, a GitHub Action to deploy a new version is required.

Add support for custom reporting

Extend the Violation interface, which currently looks like:

interface Violation {
  file: string
  line: number
  column: number
  /**
   * Possible severity values:
   * - info
   * - warning
   * - error
   * - fatal
   */
  severity: string
  message: string
}

With other fields (some should be optional) available in the checkstyle / lint reports.

Enable users to pass in an instance of a ViolationFormatter (or something else) into the configuration object, that allows formatting a Violation => string (which will be used in the danger reporting)

This should be optional, keeping the current behavior as fallback.

Add option to filter duplicated issues

When using multiple linters / scanning multiple reports with overlapping issues this can help reduce noise.

This should be an option passed in via CheckstyleConfig.

Add option to post summary comment

Add an option to post a summary comment. Comment could contain the number of reported issues and other information (files with violations, or else).

Ability to configure how to sanitize lint paths

The current implementation assumes danger is running in the same machine that generated the lint report for Android. However, it is common in CI implementations to run different stages in different hosts (eg: docker containers).

Imagine this scenario:

  • ./gradlew lint is run in a Gitlab stage in a docker container
  • We then run danger in a next stage in a different docker container.
  • The root in the 2nd container will be different than in the first one, so no matches will be found when adding comments.

One possible solution would be to not rely on the root of the current directory to replace the location in Lint files. Instead, try to find the Lint locations using the current root.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.