Skip to content

Rename template file to have .tt extension #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 11, 2025
Merged

Conversation

mgriffin
Copy link
Contributor

@mgriffin mgriffin commented Jun 9, 2025

CodeQL is giving out that one file can't be scanned, and looking at the latest job run, these are the lines that jump out about it:

2025-06-09T09:12:02.4788335Z [2025-06-09 09:12:02] [build-stdout] [2025-06-09 09:12:02] [build-stdout] �[33m WARN�[0m /home/runner/work/github-ds/github-ds/lib/generators/github/ds/templates/migration.rb:1: A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.
2025-06-09T09:12:02.4792060Z [2025-06-09 09:12:02] [build-stdout] [2025-06-09 09:12:02] [build-stdout] �[33m WARN�[0m /home/runner/work/github-ds/github-ds/lib/generators/github/ds/templates/migration.rb:1: A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.
2025-06-09T09:12:02.4796320Z [2025-06-09 09:12:02] [build-stdout] [2025-06-09 09:12:02] [build-stdout] �[33m WARN�[0m /home/runner/work/github-ds/github-ds/lib/generators/github/ds/templates/migration.rb:3: A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.
2025-06-09T09:12:02.4832203Z [2025-06-09 09:12:02] [build-stdout] [2025-06-09 09:12:02] [build-stdout] �[33m WARN�[0m /home/runner/work/github-ds/github-ds/lib/generators/github/ds/templates/migration.rb:3: A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.
2025-06-09T09:12:02.4839428Z [2025-06-09 09:12:02] [build-stdout] [2025-06-09 09:12:02] [build-stdout] �[33m WARN�[0m /home/runner/work/github-ds/github-ds/lib/generators/github/ds/templates/migration.rb:4: A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.
2025-06-09T09:12:02.4842883Z [2025-06-09 09:12:02] [build-stdout] [2025-06-09 09:12:02] [build-stdout] �[33m WARN�[0m /home/runner/work/github-ds/github-ds/lib/generators/github/ds/templates/migration.rb:10: A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.
2025-06-09T09:12:02.4846486Z [2025-06-09 09:12:02] [build-stdout] [2025-06-09 09:12:02] [build-stdout] �[33m WARN�[0m /home/runner/work/github-ds/github-ds/lib/generators/github/ds/templates/migration.rb:10: A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.
2025-06-09T09:12:02.4849905Z [2025-06-09 09:12:02] [build-stdout] [2025-06-09 09:12:02] [build-stdout] �[33m WARN�[0m /home/runner/work/github-ds/github-ds/lib/generators/github/ds/templates/migration.rb:11: A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.
2025-06-09T09:12:02.4853789Z [2025-06-09 09:12:02] [build-stdout] [2025-06-09 09:12:02] [build-stdout] �[33m WARN�[0m /home/runner/work/github-ds/github-ds/lib/generators/github/ds/templates/migration.rb:11: A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.
2025-06-09T09:12:02.4857443Z [2025-06-09 09:12:02] [build-stdout] [2025-06-09 09:12:02] [build-stdout] �[33m WARN�[0m /home/runner/work/github-ds/github-ds/lib/generators/github/ds/templates/migration.rb:13: A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.
2025-06-09T09:12:02.4860900Z [2025-06-09 09:12:02] [build-stdout] [2025-06-09 09:12:02] [build-stdout] �[33m WARN�[0m /home/runner/work/github-ds/github-ds/lib/generators/github/ds/templates/migration.rb:13: A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.
2025-06-09T09:12:02.4879284Z [2025-06-09 09:12:02] [build-stdout] [2025-06-09 09:12:02] [build-stdout] �[33m WARN�[0m /home/runner/work/github-ds/github-ds/lib/generators/github/ds/templates/migration.rb:17: A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.
2025-06-09T09:12:02.4882831Z [2025-06-09 09:12:02] [build-stdout] [2025-06-09 09:12:02] [build-stdout] �[33m WARN�[0m /home/runner/work/github-ds/github-ds/lib/generators/github/ds/templates/migration.rb:17: A parse error occurred. Check the syntax of the file. If the file is invalid, correct the error or exclude the file from analysis.

They point to lib/generators/github/ds/templates/migration.rb and I think it's the ERB code included that's tripping it up. I'm trying out renaming the template file to have a .tt extension, like other Rails generator templates do to see if it cleans up the CodeQL output.

@mgriffin
Copy link
Contributor Author

mgriffin commented Jun 9, 2025

Nice, that seems to have worked for CodeQL at least:

Analysis produced the following metric data:

|                            Metric                            | Value |
+--------------------------------------------------------------+-------+
| Total number of Ruby files that were extracted without error |    25 |
| Total number of Ruby files that were extracted with errors   |     0 |

Previously, the output looked like this:

Analysis produced the following metric data:

|                            Metric                            | Value |
+--------------------------------------------------------------+-------+
| Total number of Ruby files that were extracted without error |    25 |
| Total number of Ruby files that were extracted with errors   |     1 |

@mgriffin
Copy link
Contributor Author

mgriffin commented Jun 9, 2025

After some local testing, I think the migration to change the ID column to a bigint can be removed (8c383ae) because that's the default value for the ID column in Rails now (except for SQLite)

@mgriffin mgriffin marked this pull request as ready for review June 9, 2025 14:26
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR renames the migration template to use a .tt extension and updates the Rails generator to reference the new file name, aiming to resolve CodeQL parse errors.

  • Rename migration.rb template to migration.rb.tt
  • Update migration_template call to point to the new .tt file
  • Clean up stray whitespace in the template

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/generators/github/ds/templates/migration.rb.tt Renamed template file to .tt and removed extra lines
lib/generators/github/ds/active_record_generator.rb Updated migration_template call to use .tt file
Comments suppressed due to low confidence (2)

lib/generators/github/ds/templates/migration.rb.tt:11

  • Removing the change_column call means the id column type will no longer be altered. If the migration should still adjust the primary key to bigint, restore this line or document why it was removed.
change_column  <%= table_name %>, :id, "bigint(20) NOT NULL AUTO_INCREMENT"

@@ -9,11 +9,9 @@ def self.up

add_index <%= table_name %>, :key, :unique => true
add_index <%= table_name %>, :expires_at

change_column <%= table_name %>, :id, "bigint(20) NOT NULL AUTO_INCREMENT"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How long has this been the Rails default? I think we should restrict which Rails versions we support in the gemspec if we're going to go this route.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this was changed in Rails 6.0, in rails/rails#26266.

I'll go ahead and restrict the Rails version that we support in #72

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, let's be sure to land #72 before this PR.

@mgriffin mgriffin merged commit aa5695f into master Jun 11, 2025
27 checks passed
@mgriffin mgriffin deleted the mgriffin/template branch June 11, 2025 11:00
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.

2 participants