Code Monkey home page Code Monkey logo

sccdiff's Introduction

sccdiff

Build Status Coverage Status Time Tracker Code lines Comments

A tool to show the stats of code changes grouped by language, based on scc.

Blog post.

Usage

Usage of sccdiff:
  -all
        Include unmodified records in report.
  -basedir string
        Base directory.
  -baseref string
        Base reference. (default "HEAD")
  -groupdirs string
        Group files from directories, can be used to combine vendor, can have multiple comma separated values.
  -version
        Show app version and exit.

If there are no flags provided, sccdiff will try to check the code changes against git HEAD revision.

Result is an ASCII formatted table, suitable for Markdown.

| Language  | Files  |   Lines    |    Code    | Comments |  Blanks  | Complexity |    Bytes     |
|-----------|--------|------------|------------|----------|----------|------------|--------------|
| Go        | 2 (+2) | 385 (+385) | 298 (+298) | 1 (+1)   | 86 (+86) | 51 (+51)   | 7.4K (+7.4K) |
| Go (test) | 2 (+1) | 78 (+75)   | 58 (+56)   | 0        | 20 (+19) | 1 (+1)     | 1.8K (+1.7K) |
| License   | 1      | 21         | 17         | 0        | 4        | 0          | 1.1K (+13B)  |
| Makefile  | 1      | 40 (+1)    | 29 (+1)    | 4        | 7        | 2          | 1.2K (+42B)  |
| Markdown  | 1      | 30 (+13)   | 24 (+12)   | 0        | 6 (+1)   | 0          | 1.7K (+759B) |
| Shell     | 0 (-1) | 0 (-22)    | 0 (-15)    | 0 (-2)   | 0 (-5)   | 0          | 0B (-764B)   |
| YAML      | 5      | 308 (+3)   | 267 (+3)   | 25       | 16       | 0          | 9.8K (+49B)  |

GitHub Action

This is an example configuration to report code stats changes as pull request comment.

name: cloc
on:
  pull_request:

# Cancel the workflow in progress in newer build is about to start.
concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

jobs:
  cloc:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
        with:
          path: pr
      - name: Checkout base code
        uses: actions/checkout@v2
        with:
          ref: ${{ github.event.pull_request.base.sha }}
          path: base
      - name: Count Lines Of Code
        id: loc
        run: |
          curl -sLO https://github.com/vearutop/sccdiff/releases/download/v1.0.3/linux_amd64.tar.gz && tar xf linux_amd64.tar.gz
          sccdiff_hash=$(git hash-object ./sccdiff)
          [ "$sccdiff_hash" == "ae8a07b687bd3dba60861584efe724351aa7ff63" ] || (echo "::error::unexpected hash for sccdiff, possible tampering: $sccdiff_hash" && exit 1)
          OUTPUT=$(cd pr && ../sccdiff -basedir ../base)
          echo "${OUTPUT}"
          OUTPUT="${OUTPUT//$'\n'/%0A}"
          echo "::set-output name=diff::$OUTPUT"

      - name: Comment Code Lines
        continue-on-error: true
        uses: marocchino/sticky-pull-request-comment@v2
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          header: LOC
          message: |
            ### Lines Of Code

            ${{ steps.loc.outputs.diff }}

Example output: #2.

sccdiff's People

Contributors

vearutop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

nnnnicholas

sccdiff's Issues

Reporting Additions and Deletions separately

Currently, sccdiff shows cumulative lines of code changed (sum of additions and deletions).

For our purposes we really need to know how many lines changed. Would it be possible to break out lines added and deleted separately, in the GH Action text?

For example

Code: 8010 (+233, -150)

image

Add latest scc language support

I am attempting to use your GH action to count SLoC changed in a PR that contains Solidity language code, but it does not work.

While scc's docs say it supports Solidity, I believe sccdiff relies on a specific scc commit that does not include the latest languages.

Due to an obscure scc bug, users must download and build the package themselves to get the latest supported languages, because "for whatever reason (I really need to investigate) go @latest or @master seems to get the 3.0.0 version and not what is actually sitting in master." - boyter, author of scc.

I would love to get this working.

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.