diff --git a/.gitattributes b/.gitattributes index 976a8e7123..9d57c48166 100644 --- a/.gitattributes +++ b/.gitattributes @@ -41,6 +41,7 @@ webpack.config.js export-ignore /stripe/js/frmstrp.js export-ignore rector.php export-ignore _typos.toml export-ignore +mago.toml export-ignore /resources/ export-ignore webpack.dev.js export-ignore .browserslistrc export-ignore diff --git a/.github/workflows/mago.yml b/.github/workflows/mago.yml new file mode 100644 index 0000000000..98fdf1c06a --- /dev/null +++ b/.github/workflows/mago.yml @@ -0,0 +1,30 @@ +on: [push] + +name: Mago Code Analysis and Linting +jobs: + mago: + name: Mago + + runs-on: ubuntu-latest + + steps: + - name: "📥 Fetching Repository Contents" + uses: actions/checkout@v4.1.1 + + - name: "💽 Installing PHP" + uses: shivammathur/setup-php@v2 + with: + php-version: 8.2 + coverage: none + ini-values: display_errors=On, error_reporting=E_ALL + + - name: "⚡ Install Mago" + run: | + mkdir -p bin + curl --proto '=https' --tlsv1.2 -sSf https://carthage.software/mago.sh | bash -s -- --install-dir=bin + + - name: "✅ Mago Lint" + run: ./bin/mago lint + + - name: "🔎 Mago Analyze" + run: ./bin/mago analyze diff --git a/.gitignore b/.gitignore index d9003c6221..1f6b786789 100755 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,5 @@ sonar-project.properties .sonar_lock report-task.txt +# Mago +bin/mago diff --git a/bin/zip-plugin.sh b/bin/zip-plugin.sh index 532ad10296..90b9a39911 100755 --- a/bin/zip-plugin.sh +++ b/bin/zip-plugin.sh @@ -115,6 +115,7 @@ zip -r $zipname $destination \ -x "*/report-task.txt" \ -x "*/cypress.config.js" \ -x "*/_typos.toml" \ + -x "*/mago.toml" \ -x "formidable-ai/resources/*" \ -x "*/webpack.dev.js" \ -x "*/phpcs-sniffs/*" diff --git a/mago.toml b/mago.toml new file mode 100644 index 0000000000..ad05d365e6 --- /dev/null +++ b/mago.toml @@ -0,0 +1,189 @@ +# Welcome to Mago! +# For full documentation, see https://mago.carthage.software/tools/overview +php-version = "8.5.0" + +[source] +workspace = "." +paths = [ + "formidable.php", + "classes", + "paypal", + "stripe", + "square", + "tests", +] +includes = [] +excludes = ["vendor", "node_modules", "mago"] +extensions = ["php"] + +[formatter] +preset = "default" +use-tabs = true + +[linter] +integrations = [] + +[linter.rules] +ambiguous-function-call = { enabled = false } +literal-named-argument = { enabled = false } +array-style = { enabled = false } +strict-types = { enabled = false } +no-else-clause = { enabled = false } +no-empty = { enabled = false } +no-global = { enabled = false } +identity-comparison = { enabled = false } +prefer-static-closure = { enabled = false } +prefer-arrow-function = { enabled = false } +class-name = { enabled = false } +no-sprintf-concat = { enabled = false } +prefer-early-continue = { enabled = false } +excessive-parameter-list = { enabled = false } +no-nested-ternary = { enabled = false } +braced-string-interpolation = { enabled = false } +combine-consecutive-issets = { enabled = false } +kan-defect = { enabled = false } +no-request-variable = { enabled = false } +too-many-methods = { enabled = false } +cyclomatic-complexity = { enabled = false } +tagged-todo = { enabled = false } +strict-behavior = { enabled = false } +loop-does-not-iterate = { enabled = false } +explicit-octal = { enabled = false } +no-redundant-math = { enabled = false } +no-error-control-operator = { enabled = false } +no-closing-tag = { enabled = false } +too-many-properties = { enabled = false } +sensitive-parameter = { enabled = false } +halstead = { enabled = false } # Consider enabling this soon. +use-compound-assignment = { enabled = false } # Consider enabling this soon. +require-preg-quote-delimiter = { enabled = false } +no-assign-in-condition = { enabled = false } +no-insecure-comparison = { enabled = false } # Consider enabling this soon. +excessive-nesting = { enabled = false } # Consider enabling this soon. +no-redundant-parentheses = { enabled = false } # Fix this first. +inline-variable-return = { enabled = false } # Fix this first. +no-redundant-method-override = { enabled = false } # Fix this first. + +[analyzer] +plugins = [] +find-unused-definitions = true +find-unused-expressions = false +analyze-dead-code = true +memoize-properties = true +allow-possibly-undefined-array-keys = true +check-throws = false +check-missing-override = false +find-unused-parameters = false +strict-list-index-checks = false +no-boolean-literal-comparison = false +check-missing-type-hints = false +register-super-globals = true +ignore = [ + "invalid-param-tag", + "malformed-docblock-comment", + "non-existent-function", + "undefined-variable", + "mixed-argument", + "redundant-condition", + "mixed-array-access", + "mixed-operand", + "mixed-property-access", + "invalid-global", + "possibly-false-argument", + "unknown-class-instantiation", + "unused-method", + "non-existent-method", + "invalid-return-statement", + "invalid-iterator", + "less-specific-nested-argument-type", + "reference-to-undefined-variable", + "mixed-return-statement", + "redundant-logical-operation", + "undefined-int-array-index", + "possibly-invalid-argument", + "mixed-assignment", + "possibly-null-argument", + "invalid-argument", + "invalid-operand", + "less-specific-return-statement", + "non-existent-constant", + "ambiguous-object-property-access", + "less-specific-argument", + "invalid-type-cast", + "reference-constraint-violation", + "possibly-false-operand", + "nullable-return-statement", + "array-to-string-conversion", + "possibly-undefined-string-array-index", + "redundant-comparison", + "mixed-array-assignment", + "generic-object-iteration", + "mixed-method-access", + "mixed-array-assignment", + "redundant-type-comparison", + "false-argument", # Fix this soon + "mixed-property-type-coercion", + "invalid-method-access", + "possible-method-access-on-null", + "possibly-null-property-access", + "mixed-array-index", + "less-specific-nested-return-statement", + "null-operand", + "invalid-property-access", + "impossible-assignment", + "non-existent-class", + "never-return", + "non-existent-class-like", + "invalid-member-selector", + "non-existent-property", + "invalid-member-selector", + "too-few-arguments", + "impossible-type-comparison", # Fix this soon + "string-member-selector", + "impossible-condition", + "falsable-return-statement", + "property-type-coercion", + "invalid-property-assignment-value", + "unused-property", + "possibly-undefined-variable", + "impossible-nonnull-entry-check", + "ambiguous-object-method-access", + "null-array-index", + "possibly-null-operand", + "missing-return-statement", + "incompatible-parameter-type", + "null-array-access", + "null-argument", + "mismatched-array-index", + "no-value", + "possibly-invalid-operand", + "non-documented-property", + "conflicting-reference-constraint", + "redundant-null-coalesce", + "unsafe-instantiation", + "invalid-destructuring-source", + "unknown-iterator-type", + "invalid-array-access", + "undefined-variable-in-closure-use", + "possibly-false-iterator", + "invalid-unset", + "redundant-isset-check", + "possibly-invalid-iterator", + "undefined-string-array-index", + "invalid-array-element-key", + "deprecated-function", + "redundant-isset-check", + "mixed-clone", + "invalid-array-index", + "possibly-null-array-access", + "possibly-null-iterator", + "false-operand", + "null-property-access", + "redundant-key-check", + "possibly-null-array-index", + "invalid-property-read", + "possibly-invalid-clone", + "ambiguous-instantiation-target", + "method-access-on-null", + "null-iterator", +] \ No newline at end of file diff --git a/stripe/helpers/FrmTransLiteListHelper.php b/stripe/helpers/FrmTransLiteListHelper.php index 2c579d8c0f..54fac5e857 100755 --- a/stripe/helpers/FrmTransLiteListHelper.php +++ b/stripe/helpers/FrmTransLiteListHelper.php @@ -96,15 +96,13 @@ private function get_table_query() { } // @codingStandardsIgnoreStart - $query = $wpdb->prepare( + return $wpdb->prepare( "FROM `{$wpdb->prefix}{$table_name}` p JOIN `{$wpdb->prefix}frm_items` i ON p.item_id = i.id WHERE i.form_id = %d", $form_id ); // @codingStandardsIgnoreEnd - - return $query; } /**