Skip to content

Added category exclusion filters for LOC calculation (UI and Badges)#163

Open
cookieukw wants to merge 12 commits into
pajecawav:masterfrom
cookieukw:master
Open

Added category exclusion filters for LOC calculation (UI and Badges)#163
cookieukw wants to merge 12 commits into
pajecawav:masterfrom
cookieukw:master

Conversation

@cookieukw

Copy link
Copy Markdown

Description

This PR introduces a new feature that allows users to exclude specific file categories (like Lockfiles, Configs, Build Scripts, etc.) from the overall Lines of Code (LOC) calculation. This provides a much more accurate representation of the actual source code written by developers

Key Changes:

  • "Exclude" Menu: Added a new dropdown menu next to the search input, allowing users to quickly toggle predefined exclusion filters
  • URL Synchronization: Active filters are synced to the URL (?activeFilters=...) so that the exact state can be easily shared
  • Badge & OG Image Support: The activeFilters parameter is fully supported by the badge (/badge) and Open Graph image (/og-image) API endpoints, meaning users can now generate shields.io badges that exclude lockfiles/configs using ?activeFilters=jsonConfigs,lockfiles
  • Backend handling: Instead of modifying the core backend, the filtering math is done in the Node.js API wrapper (src/lib/ghloc/api.ts). It traverses the returned JSON, strips out the ignored files, and automatically recalculates the total loc and locByLangs dictionary before passing it to the frontend
  • Docs: Updated README.md with an example of how to use this parameter for badges

Filter Categories Added:

  • jsonConfigs (e.g. package.json, tsconfig.json)
  • lockfiles (e.g. pnpm-lock.yaml, go.sum)
  • buildScripts (e.g. Makefile, webpack.config.js)
  • environment (e.g. Dockerfile, .env)
  • editorGit (e.g. .gitignore, .prettierrc)
  • cachesAndBinaries (e.g. .png, .zip)

How I tested this:

  • Tested the filtering in the UI (checking different combinations and verifying that the LOC count and file tree update correctly)
  • Created a local HTTPS tunnel (via localhost.run/ngrok) to expose the local API endpoint to the internet and successfully rendered the actual SVGs on the live shields.io server
  • Passed multiple query combinations to the badge URL to ensure the API safely handles parsing and ignores invalid values

exclude option

Captura_de_tela_20260620_194752

exclude menu

Captura_de_tela_20260620_194800

total lines (without exclude options)

Captura_de_tela_20260620_194821

with only three first exclude options

Captura_de_tela_20260620_194830

but is the badge (buildScripts, Clockfiles, jsonConfigs)

Captura_de_tela_20260620_201257

with only three last exclude options

Captura_de_tela_20260620_194837

but is the badge (cachesAndBinaries, editorGit, environment)

Captura_de_tela_20260620_201549

with all exclude options

Captura_de_tela_20260620_194844

but is the badge (buildScripts, Clockfiles, jsonConfigs, cachesAndBinaries, editorGit, environment)

Captura_de_tela_20260620_202004

@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

@cookieukw is attempting to deploy a commit to the pajecawav's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant