{"id":27767955,"url":"https://github.com/bernaferrari/flutterresourceranker","last_synced_at":"2025-08-25T20:11:27.339Z","repository":{"id":107061167,"uuid":"242200896","full_name":"bernaferrari/FlutterResourceRanker","owner":"bernaferrari","description":"Find underused colors, overused magical numbers and the largest classes in any Flutter project.","archived":false,"fork":false,"pushed_at":"2020-02-21T18:09:48.000Z","size":698,"stargazers_count":23,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-29T19:56:30.031Z","etag":null,"topics":["detekt","flutter","kotlin-script","lint"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bernaferrari.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-02-21T18:04:51.000Z","updated_at":"2025-01-13T11:01:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"5a5a19a6-c42d-4776-9c04-732a239639cf","html_url":"https://github.com/bernaferrari/FlutterResourceRanker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bernaferrari/FlutterResourceRanker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bernaferrari%2FFlutterResourceRanker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bernaferrari%2FFlutterResourceRanker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bernaferrari%2FFlutterResourceRanker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bernaferrari%2FFlutterResourceRanker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bernaferrari","download_url":"https://codeload.github.com/bernaferrari/FlutterResourceRanker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bernaferrari%2FFlutterResourceRanker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272124753,"owners_count":24877720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-25T02:00:12.092Z","response_time":1107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["detekt","flutter","kotlin-script","lint"],"created_at":"2025-04-29T19:56:26.388Z","updated_at":"2025-08-25T20:11:27.327Z","avatar_url":"https://github.com/bernaferrari.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"Flutter Resource Ranker\n=================\n\nIt is easy to overuse colors, write magical numbers or long classes. This project has a script to help you detect these.\nThis was inspired by a [tweet from Emma Vanbrabant](https://twitter.com/emmaguy/status/1229356566819852288), where she ranked Android color resources. Seeing the usefulness, I decided replicating and expanding for Flutter. It can do the following:\n\n ![GIF](screenshot.png?raw=true)\n \n### What it can do\nDetect color usage (either `Color(...)` or `Color primary = ...`):\n\n- See frequency of hardcoded colors. Consider using a variable for better maintainability and multi-theme support.\n- Detect colors used in few places. When Chrome was redesigned, the team discovered it had [95 shades of grey](https://medium.com/@san_toki/unboxing-chrome-f6af7b8161a2). They managed to reduce to 8. Material Design Theme [supports 12 categories of color](https://material.io/design/material-theming/implementing-your-theme.html). Try to keep it simple(r).\n- See how detected colors contrast with black or white. It follows [WACG recommendations](https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html) and is useful to see if a heavily used color doesn't have enough contrast with black or white.\n\nDetect class size (counts the number of `;` inside each class):\n- Inspired by Detekt [LongMethod](https://arturbosch.github.io/detekt/complexity.html#longmethod).\nUseful to see who are the largest classes and if there is any that is an outlier (i.e. has many more lines of code than others).\n- In the future, this script could be configured for use in a CI system to fail/reject a commit or pull request that has a huge class.\n\nDetect magical numbers (finds every number different than [-1,0,1,2] without a `;` or `,` nearby):\n- Inspired by Detekt [MagicNumber](https://arturbosch.github.io/detekt/style.html#magicnumber). Detect numbers that are not attributed to a variable or method call (as long as there is a `,` after the number). The script can be customised to be more or less strict.\n\nGetting Started\n---------------\nThe script was written in Kotlin and depends on JVM (for File access). If you need to install Kotlin for command line access, [check here](https://kotlinlang.org/docs/tutorials/command-line.html) (`brew install kotlin`).\n\nThe script only scans `.dart` files.\n\n```\nUSAGE:\n$ ./resourceranker.kts \u003cproject directory\u003e [OPTIONS]\n$ kotlinc -script resourceranker.kts \u003cproject directory\u003e [OPTIONS]\n\nOPTIONS:\ncolor       How many colors you are using and how many times\ncontrast    How many colors and how they compare to black and white\nnum         How many magical numbers you are using and how many times\nclass       How many lines each class has.\nhelp        Show this text.\n\u003cint\u003e       Max limit. If 0, shows all elements. Default is 10.\n\nEXAMPLE:\n$ ./resourceranker.kts documents/project color 10\n$ ./resourceranker.kts ../ class 0\n$ ./resourceranker.kts ../../ contrast 5\n$ ./resourceranker.kts ./ num\n$ ./resourceranker.kts desktop class color 0\n```\n\n ![GIF](contrast.png?raw=true)\n\n\nIssue Tracking\n-------\nFound a bug? Have an idea for an improvement? Would you like to add to CI or convert to other language? Feel free to [add an issue](../../issues).\n\nLicense\n-------\n\nCopyright 2020 Bernardo Ferrari.\n\nLicensed to the Apache Software Foundation (ASF) under one or more contributor\nlicense agreements.  See the NOTICE file distributed with this work for\nadditional information regarding copyright ownership.  The ASF licenses this\nfile to you under the Apache License, Version 2.0 (the \"License\"); you may not\nuse this file except in compliance with the License.  You may obtain a copy of\nthe License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\nWARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the\nLicense for the specific language governing permissions and limitations under\nthe License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbernaferrari%2Fflutterresourceranker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbernaferrari%2Fflutterresourceranker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbernaferrari%2Fflutterresourceranker/lists"}