From f053442c61bb7ae168ac254c8dc39dac5b4caf99 Mon Sep 17 00:00:00 2001 From: Morgante Pell Date: Sat, 13 Apr 2024 11:32:18 -0700 Subject: [PATCH] fix: update pattern format (#190) --- .grit/patterns/css/aspect_ratio.md | 2 -- .grit/patterns/go/cloudflare_go_v2.md | 13 +++++++------ .grit/patterns/java/no_big_decimal_double.md | 4 +--- .../js/intelligent_useEffect_to_useLayoutEffect.md | 2 +- .grit/patterns/js/no_return_assign.md | 9 ++------- .grit/patterns/js/no_unsafe_negation.md | 2 -- .grit/patterns/js/prefer_early_return.md | 2 -- .../python/_test_add_multiple_bare_imports.md | 3 ++- .grit/patterns/python/_test_add_one_bare_import.md | 3 ++- .grit/patterns/python/_test_ensure_import_from.md | 3 ++- .grit/patterns/solidity/EtherTransfer.md | 2 -- .grit/patterns/solidity/NestedLoop.md | 2 -- .grit/patterns/solidity/NoMulDivRoundUp.md | 2 -- .grit/patterns/solidity/UpgradableProxyPattern.md | 2 -- .grit/patterns/sql/add_pg_unit_test.md | 2 +- .grit/patterns/sql/oracle_quote_procedure.md | 4 ++-- .grit/patterns/sql/oracle_to_pg.md | 2 +- .grit/patterns/yaml/concourse_v7.md | 11 +++++++++++ old_patterns/NonTrivialMath.md | 2 -- old_patterns/ReentrancyBeforeAndAfter.md | 2 -- old_patterns/ReentrancyLowRisk.md | 2 -- old_patterns/ReentrancyNoBefore.md | 2 -- wip/StyledJSXToCSSModules.md | 2 -- 23 files changed, 32 insertions(+), 48 deletions(-) diff --git a/.grit/patterns/css/aspect_ratio.md b/.grit/patterns/css/aspect_ratio.md index a0c5dd21..99d39f5b 100644 --- a/.grit/patterns/css/aspect_ratio.md +++ b/.grit/patterns/css/aspect_ratio.md @@ -2,8 +2,6 @@ title: Aspect ratio --- -# {{ page.title }} - ```grit language css diff --git a/.grit/patterns/go/cloudflare_go_v2.md b/.grit/patterns/go/cloudflare_go_v2.md index ff7fb8ef..3dab55ac 100644 --- a/.grit/patterns/go/cloudflare_go_v2.md +++ b/.grit/patterns/go/cloudflare_go_v2.md @@ -11,6 +11,13 @@ Future migrations will be more seamless as we will be automatically generating t {% /note %} +This migration can be applied automatically using the [Grit CLI](https://docs.grit.io/cli/quickstart): + +``` +grit apply cloudflare_go_v2 +``` + + ```grit language go @@ -651,12 +658,6 @@ file($body) where { } ``` -This migration can be applied automatically using the [Grit CLI](https://docs.grit.io/cli/quickstart): - -``` -grit apply cloudflare_go_v2 -``` - ## Client construction with API key and email Old: diff --git a/.grit/patterns/java/no_big_decimal_double.md b/.grit/patterns/java/no_big_decimal_double.md index 5d9d10bf..d73151ea 100644 --- a/.grit/patterns/java/no_big_decimal_double.md +++ b/.grit/patterns/java/no_big_decimal_double.md @@ -1,10 +1,8 @@ --- -title: "BigDecimal(double)" should not be used +title: "`BigDecimal(double)` should not be used" tags: [java] --- -# "BigDecimal(double)" should not be used - Because of floating point imprecision, the `BigDecimal(double)` constructor can be somewhat unpredictable. It is better to use `BigDecimal.valueOf(double)`. diff --git a/.grit/patterns/js/intelligent_useEffect_to_useLayoutEffect.md b/.grit/patterns/js/intelligent_useEffect_to_useLayoutEffect.md index fe53c330..845789e4 100644 --- a/.grit/patterns/js/intelligent_useEffect_to_useLayoutEffect.md +++ b/.grit/patterns/js/intelligent_useEffect_to_useLayoutEffect.md @@ -1,5 +1,5 @@ --- -title: [React2Hooks] Intelligent useEffect vs useLayoutEffect +title: "[React2Hooks] Intelligent useEffect vs useLayoutEffect" tags: [fix] --- diff --git a/.grit/patterns/js/no_return_assign.md b/.grit/patterns/js/no_return_assign.md index dd8b650a..c72bf7a7 100644 --- a/.grit/patterns/js/no_return_assign.md +++ b/.grit/patterns/js/no_return_assign.md @@ -3,10 +3,9 @@ title: Hoist assignment out of `return` statement tags: [good, se] --- -# {{ page.title }} - -This rule hoists the assignments out of `return`. Does not apply when assignment is wrapped in parentheses. +This rule hoists the assignments out of `return`. Because an assignment, `=` is easy to confuse with a comparison, `==`, The best practice is not to use any assignments in return statements. +This does not apply when assignment is wrapped in parentheses. ```grit engine marzano(0.1) @@ -21,10 +20,6 @@ language js } => `$assignment;\n return $left;` ``` -``` -An assignment, `=`, is easy to confuse with a comparison, `==`. The best practice is not to use any assignments in return statements. -``` - ## Hoist `=` from `return` statement ```javascript diff --git a/.grit/patterns/js/no_unsafe_negation.md b/.grit/patterns/js/no_unsafe_negation.md index 03cc759f..bb437899 100644 --- a/.grit/patterns/js/no_unsafe_negation.md +++ b/.grit/patterns/js/no_unsafe_negation.md @@ -3,8 +3,6 @@ title: Rewrite `!key in col` ⇒ `!(key in col)` tags: [fix] --- -# {{ page.title }} - Negates `key` instead of the entire expression, which is likely a bug. The intent is usually to negate the entire relation expression. diff --git a/.grit/patterns/js/prefer_early_return.md b/.grit/patterns/js/prefer_early_return.md index c39eeade..8ec2af37 100644 --- a/.grit/patterns/js/prefer_early_return.md +++ b/.grit/patterns/js/prefer_early_return.md @@ -3,8 +3,6 @@ title: PreferEarlyReturn tags: [lint, style] --- -# {{ page.title }} - Prefer to use early returns to keep functions flat. diff --git a/.grit/patterns/python/_test_add_multiple_bare_imports.md b/.grit/patterns/python/_test_add_multiple_bare_imports.md index d489421c..26eaf19f 100644 --- a/.grit/patterns/python/_test_add_multiple_bare_imports.md +++ b/.grit/patterns/python/_test_add_multiple_bare_imports.md @@ -21,6 +21,7 @@ language python ```python +# This is an empty block ``` ```python @@ -28,7 +29,7 @@ import math import re import json - +# This is an empty block ``` ## Add missing imports diff --git a/.grit/patterns/python/_test_add_one_bare_import.md b/.grit/patterns/python/_test_add_one_bare_import.md index 69c37516..d00ca05f 100644 --- a/.grit/patterns/python/_test_add_one_bare_import.md +++ b/.grit/patterns/python/_test_add_one_bare_import.md @@ -17,12 +17,13 @@ language python ```python +# Add one ``` ```python import math - +# Add one ``` ## Do not add duplicate bare import diff --git a/.grit/patterns/python/_test_ensure_import_from.md b/.grit/patterns/python/_test_ensure_import_from.md index ee96bfec..7c700c64 100644 --- a/.grit/patterns/python/_test_ensure_import_from.md +++ b/.grit/patterns/python/_test_ensure_import_from.md @@ -17,12 +17,13 @@ language python ```python +# Empty block ``` ```python from math import prod - +# Empty block ``` ## Add one more name to source diff --git a/.grit/patterns/solidity/EtherTransfer.md b/.grit/patterns/solidity/EtherTransfer.md index 8f096a86..2b0e6fd9 100644 --- a/.grit/patterns/solidity/EtherTransfer.md +++ b/.grit/patterns/solidity/EtherTransfer.md @@ -2,8 +2,6 @@ title: Ether Transfer --- -# {{ page.title }} - ```grit language sol diff --git a/.grit/patterns/solidity/NestedLoop.md b/.grit/patterns/solidity/NestedLoop.md index 4720d48d..69fc31bd 100644 --- a/.grit/patterns/solidity/NestedLoop.md +++ b/.grit/patterns/solidity/NestedLoop.md @@ -3,8 +3,6 @@ title: Nested Loop tags: [reentrancy, vulnerability] --- -# {{ page.title }} - Inspect nested loops. diff --git a/.grit/patterns/solidity/NoMulDivRoundUp.md b/.grit/patterns/solidity/NoMulDivRoundUp.md index 43820f5c..2027fe42 100644 --- a/.grit/patterns/solidity/NoMulDivRoundUp.md +++ b/.grit/patterns/solidity/NoMulDivRoundUp.md @@ -2,8 +2,6 @@ title: NoMulDiv --- -# {{ page.title }} - Say we do not want `mulDivRoundUp`. ```grit diff --git a/.grit/patterns/solidity/UpgradableProxyPattern.md b/.grit/patterns/solidity/UpgradableProxyPattern.md index def5af6c..6bd1fa6a 100644 --- a/.grit/patterns/solidity/UpgradableProxyPattern.md +++ b/.grit/patterns/solidity/UpgradableProxyPattern.md @@ -3,8 +3,6 @@ title: Upgradable Proxy Pattern tags: [reentrancy, vulnerability] --- -# {{ page.title }} - Looking for variations of the upgradable proxy pattern. diff --git a/.grit/patterns/sql/add_pg_unit_test.md b/.grit/patterns/sql/add_pg_unit_test.md index 26000b86..0a4dcc32 100644 --- a/.grit/patterns/sql/add_pg_unit_test.md +++ b/.grit/patterns/sql/add_pg_unit_test.md @@ -45,9 +45,9 @@ CREATE PROCEDURE remove_emp(employee_id int) AS tot_emps := tot_emps - 1; END; + -- Check that 'remove_emp' has been translated into valid plpgsql SELECT has_function('remove_emp'); SELECT is_procedure('remove_emp'); SELECT function_lang_is('remove_emp', 'pgplsql' ); - ``` \ No newline at end of file diff --git a/.grit/patterns/sql/oracle_quote_procedure.md b/.grit/patterns/sql/oracle_quote_procedure.md index 47aa7b72..dbe37c2c 100644 --- a/.grit/patterns/sql/oracle_quote_procedure.md +++ b/.grit/patterns/sql/oracle_quote_procedure.md @@ -1,5 +1,5 @@ --- -title: Oracle to PG: Dollar quote stored procedure body +title: "Oracle to PG: Dollar quote stored procedure body" --- In Postgres, function and procedure bodies need to be wrapped in $$dollar quotes$$. @@ -40,4 +40,4 @@ CREATE PROCEDURE remove_emp (employee_id int) AS tot_emps := tot_emps - 1; END; $$ LANGUAGE plpgsql; -``` \ No newline at end of file +``` diff --git a/.grit/patterns/sql/oracle_to_pg.md b/.grit/patterns/sql/oracle_to_pg.md index 3d740fa7..939381cd 100644 --- a/.grit/patterns/sql/oracle_to_pg.md +++ b/.grit/patterns/sql/oracle_to_pg.md @@ -69,9 +69,9 @@ CREATE PROCEDURE remove_emp(employee_id NUMERIC) AS END; $$ LANGUAGE plpgsql; + -- Check that 'remove_emp' has been translated into valid plpgsql SELECT has_function('remove_emp'); SELECT is_procedure('remove_emp'); SELECT function_lang_is('remove_emp', 'pgplsql' ); - ``` diff --git a/.grit/patterns/yaml/concourse_v7.md b/.grit/patterns/yaml/concourse_v7.md index 5981d94a..90c0d2e5 100644 --- a/.grit/patterns/yaml/concourse_v7.md +++ b/.grit/patterns/yaml/concourse_v7.md @@ -136,6 +136,7 @@ jobs: code: one-js output_mapping: code: a-js + - task: create-file-2 params: FUNCTION: file2-js @@ -143,6 +144,7 @@ jobs: code: one-js output_mapping: code: a-js + - task: create-file-3 params: FUNCTION: file3-js @@ -150,6 +152,7 @@ jobs: code: one-js output_mapping: code: a-js + - task: create-file-4 params: FUNCTION: file1-js @@ -157,6 +160,7 @@ jobs: code: two-js output_mapping: code: a-js + - task: create-file-5 params: FUNCTION: file2-js @@ -164,6 +168,7 @@ jobs: code: two-js output_mapping: code: a-js + - task: create-file-6 params: FUNCTION: file3-js @@ -171,6 +176,7 @@ jobs: code: two-js output_mapping: code: a-js + - task: create-file-7 params: FUNCTION: file1-js @@ -178,6 +184,7 @@ jobs: code: one-js output_mapping: code: b-js + - task: create-file-8 params: FUNCTION: file2-js @@ -185,6 +192,7 @@ jobs: code: one-js output_mapping: code: b-js + - task: create-file-9 params: FUNCTION: file3-js @@ -192,6 +200,7 @@ jobs: code: one-js output_mapping: code: b-js + - task: create-file-10 params: FUNCTION: file1-js @@ -199,6 +208,7 @@ jobs: code: two-js output_mapping: code: b-js + - task: create-file-11 params: FUNCTION: file2-js @@ -206,6 +216,7 @@ jobs: code: two-js output_mapping: code: b-js + - task: create-file-12 params: FUNCTION: file3-js diff --git a/old_patterns/NonTrivialMath.md b/old_patterns/NonTrivialMath.md index cf9b04f4..0f7211c6 100644 --- a/old_patterns/NonTrivialMath.md +++ b/old_patterns/NonTrivialMath.md @@ -2,8 +2,6 @@ title: Non-trivial math --- -# {{ page.title }} - ```grit or { // ds-math diff --git a/old_patterns/ReentrancyBeforeAndAfter.md b/old_patterns/ReentrancyBeforeAndAfter.md index ea19d822..b18f835f 100644 --- a/old_patterns/ReentrancyBeforeAndAfter.md +++ b/old_patterns/ReentrancyBeforeAndAfter.md @@ -2,8 +2,6 @@ title: Reentrancy, assignments both before and after --- -# {{ page.title }} - A transfer with member assignments both before and after the transfer. See case 2 here: https://github.com/runtimeverification/amp/issues/39#issuecomment-1137314683 diff --git a/old_patterns/ReentrancyLowRisk.md b/old_patterns/ReentrancyLowRisk.md index a2fba4f5..b2f59214 100644 --- a/old_patterns/ReentrancyLowRisk.md +++ b/old_patterns/ReentrancyLowRisk.md @@ -2,8 +2,6 @@ title: Reentrancy, not last line --- -# {{ page.title }} - Member assignemnt just before the transfer, but transfer not on the last line See case 3 here: https://github.com/runtimeverification/amp/issues/39#issuecomment-1137314683 diff --git a/old_patterns/ReentrancyNoBefore.md b/old_patterns/ReentrancyNoBefore.md index 96b91922..4dadd748 100644 --- a/old_patterns/ReentrancyNoBefore.md +++ b/old_patterns/ReentrancyNoBefore.md @@ -2,8 +2,6 @@ title: Reentrancy, no assignment before --- -# {{ page.title }} - No field assignment before a transfer. See case 1 here: https://github.com/runtimeverification/amp/issues/39#issuecomment-1137314683 diff --git a/wip/StyledJSXToCSSModules.md b/wip/StyledJSXToCSSModules.md index 3e5c3ee4..844e0e01 100644 --- a/wip/StyledJSXToCSSModules.md +++ b/wip/StyledJSXToCSSModules.md @@ -2,8 +2,6 @@ title: Convert Styled JSX to CSS Modules --- -# {{ page.title }} - Extract all Styled JSX from a particular file and move it to CSS Module files. - If there are multiple components in a given file, we create separate CSS Module file for each one.