FIX: Make string constants upper snake case

FIX: Make string constants upper snake case

diff --git a/lib/discourse_code_review/github_category_syncer.rb b/lib/discourse_code_review/github_category_syncer.rb
index 13386cc..860502c 100644
--- a/lib/discourse_code_review/github_category_syncer.rb
+++ b/lib/discourse_code_review/github_category_syncer.rb
@@ -2,7 +2,7 @@
 
 module DiscourseCodeReview
   module GithubCategorySyncer
-    GithubRepoName = "GitHub Repo Name"
+    GITHUB_REPO_NAME = "GitHub Repo Name"
 
     class << self
       def ensure_category(repo_name:)
@@ -12,7 +12,7 @@ module DiscourseCodeReview
               id:
                 CategoryCustomField
                   .select(:category_id)
-                  .where(name: GithubRepoName, value: repo_name)
+                  .where(name: GITHUB_REPO_NAME, value: repo_name)
             ).first
 
           if category.nil?
@@ -24,7 +24,7 @@ module DiscourseCodeReview
                 user: Discourse.system_user
               )
 
-            category.custom_fields[GithubRepoName] = repo_name
+            category.custom_fields[GITHUB_REPO_NAME] = repo_name
             category.save_custom_fields
           end
 
@@ -34,19 +34,19 @@ module DiscourseCodeReview
 
       def each_repo_name(&blk)
         CategoryCustomField
-          .where(name: GithubRepoName)
+          .where(name: GITHUB_REPO_NAME)
           .pluck(:value)
           .each(&blk)
       end
 
       def github_repo_category_fields
         CategoryCustomField
-          .where(name: GithubRepoName)
+          .where(name: GITHUB_REPO_NAME)
           .include(:category)
       end
 
       def get_repo_name_from_topic(topic)
-        topic.category.custom_fields[GithubRepoName]
+        topic.category.custom_fields[GITHUB_REPO_NAME]
       end
 
       private
diff --git a/lib/discourse_code_review/github_pr_syncer.rb b/lib/discourse_code_review/github_pr_syncer.rb
index ae9de85..2a38296 100644
--- a/lib/discourse_code_review/github_pr_syncer.rb
+++ b/lib/discourse_code_review/github_pr_syncer.rb
@@ -2,9 +2,9 @@
 
 module DiscourseCodeReview
   class GithubPRSyncer
-    GithubNodeId = "github node id"
-    GithubIssueNumber = "github issue number"
-    GithubThreadId = "github thread id"
+    GITHUB_NODE_ID = "github node id"
+    GITHUB_ISSUE_NUMBER = "github issue number"
+    GITHUB_THREAD_ID = "github thread id"
 
     class GithubPRPoster
       def initialize(topic:, author:, github_id:, created_at:)
@@ -84,7 +84,7 @@ module DiscourseCodeReview
           ensure_pr_post(body: body, post_type: :small_action, action_code: 'renamed') do |post|
             topic = post.topic
 
-            issue_number = topic.custom_fields[GithubIssueNumber]
+            issue_number = topic.custom_fields[GITHUB_ISSUE_NUMBER]
 
             topic.title = "#{event.new_title} (PR ##{issue_number})"
             topic.save!(validate: false)
@@ -118,7 +118,7 @@ module DiscourseCodeReview
           last_post.created_at = created_at
           last_post.save!
 
-          last_post.custom_fields[GithubNodeId] = github_id
+          last_post.custom_fields[GITHUB_NODE_ID] = github_id
           last_post.save_custom_fields
         end
       end
@@ -128,7 +128,7 @@ module DiscourseCodeReview
           id:
             PostCustomField
               .select(:post_id)
-              .where(name: GithubNodeId, value: github_id)
+              .where(name: GITHUB_NODE_ID, value: github_id)
               .limit(1)
         ).first
       end
@@ -151,7 +151,7 @@ module DiscourseCodeReview
                 id:
                   PostCustomField
                     .select(:post_id)
-                    .where(name: GithubNodeId, value: reply_to_github_id)
+                    .where(name: GITHUB_NODE_ID, value: reply_to_github_id)
                     .limit(1)
               ).pluck(:post_number).first
             end
@@ -170,8 +170,8 @@ module DiscourseCodeReview
               )
             end
 
-          post.custom_fields[GithubNodeId] = github_id
-          post.custom_fields[GithubThreadId] = thread_id if thread_id.present?
+          post.custom_fields[GITHUB_NODE_ID] = github_id
+          post.custom_fields[GITHUB_THREAD_ID] = thread_id if thread_id.present?
           post.save_custom_fields
 
           yield post if block_given?
@@ -251,9 +251,9 @@ module DiscourseCodeReview
       topic = post.topic
       user = post.user
 
-      if post.post_number > 1 && !post.whisper? && post.custom_fields[GithubNodeId].nil?
-        repo_name = topic.category.custom_fields[GithubCategorySyncer::GithubRepoName]
-        issue_number = topic.custom_fields[GithubIssueNumber]
+      if post.post_number > 1 && !post.whisper? && post.custom_fields[GITHUB_NODE_ID].nil?
+        repo_name = topic.category.custom_fields[GithubCategorySyncer::GITHUB_REPO_NAME]
+        issue_number = topic.custom_fields[GITHUB_ISSUE_NUMBER]
 
         if repo_name && issue_number
           issue_number = issue_number.to_i
@@ -266,7 +266,7 @@ module DiscourseCodeReview
 
           thread_id =
             if reply_to.present?
-              reply_to.custom_fields[GithubThreadId]
+              reply_to.custom_fields[GITHUB_THREAD_ID]
             end
 
           post_user_name = user.name || user.username
@@ -313,7 +313,7 @@ module DiscourseCodeReview
         id:
           TopicCustomField
             .select(:topic_id)
-            .where(name: GithubNodeId, value: github_id)
+            .where(name: GITHUB_NODE_ID, value: github_id)
             .limit(1)
       ).first
     end
@@ -339,8 +339,8 @@ module DiscourseCodeReview
               ).topic
             end
 
-          topic.custom_fields[GithubNodeId] = github_id
-          topic.custom_fields[GithubIssueNumber] = issue_number.to_s
+          topic.custom_fields[GITHUB_NODE_ID] = github_id
+          topic.custom_fields[GITHUB_ISSUE_NUMBER] = issue_number.to_s
           topic.save_custom_fields
         end
 
diff --git a/lib/discourse_code_review/github_repo.rb b/lib/discourse_code_review/github_repo.rb
index 4569459..9b65b46 100644
--- a/lib/discourse_code_review/github_repo.rb
+++ b/lib/discourse_code_review/github_repo.rb
@@ -5,8 +5,7 @@ module DiscourseCodeReview
 
     attr_reader :name, :octokit_client
 
-    LastCommit = 'last commit'
-    CommentPage = 'comment page'
+    LAST_COMMIT = 'last commit'
 
     LINE_END = "52fc72dfa9cafa9da5e6266810b884ae"
     FIELD_END = "52fc72dfa9cafa9da5e6266810b884ff"
@@ -23,7 +22,7 @@ module DiscourseCodeReview
     end
 
     def last_commit
-      commit_hash = PluginStore.get(DiscourseCodeReview::PluginName, LastCommit + @name)
+      commit_hash = PluginStore.get(DiscourseCodeReview::PluginName, LAST_COMMIT + @name)
       if commit_hash.present? && !commit_hash_valid?(commit_hash)
         Rails.logger.warn("Discourse Code Review: Failed to detect commit hash `#{commit_hash}` in #{path}, resetting last commit hash.")
         commit_hash = nil
@@ -37,7 +36,7 @@ module DiscourseCodeReview
     end
 
     def last_commit=(v)
-      PluginStore.set(DiscourseCodeReview::PluginName, LastCommit + @name, v)
+      PluginStore.set(DiscourseCodeReview::PluginName, LAST_COMMIT + @name, v)
       v
     end
 
diff --git a/lib/discourse_code_review/github_user_syncer.rb b/lib/discourse_code_review/github_user_syncer.rb
index 2d8a56d..31aeea0 100644
--- a/lib/discourse_code_review/github_user_syncer.rb
+++ b/lib/discourse_code_review/github_user_syncer.rb
@@ -15,7 +15,7 @@ module DiscourseCodeReview
             id:
               UserCustomField
                 .select(:user_id)
-                .where(name: GithubId, value: github_id)
+                .where(name: GITHUB_ID, value: github_id)
                 .limit(1)
           )
         end
@@ -27,7 +27,7 @@ module DiscourseCodeReview
               id:
                 UserCustomField
                   .select(:user_id)
-                  .where(name: GithubLogin, value: github_login)
+                  .where(name: GITHUB_LOGIN, value: github_login)
                   .limit(1)
             )
         end

[... diff too long, it was truncated ...]

GitHub sha: 30e223ed

1 Like