fix lint errors

This commit is contained in:
Chris Zhu
2024-11-13 12:57:26 -08:00
parent 4233eaa1ba
commit c933ce519c
39 changed files with 55 additions and 55 deletions

View File

@@ -6,3 +6,5 @@ inherit_gem: { rubocop-rails-omakase: rubocop.yml }
# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]`
# Layout/SpaceInsideArrayLiteralBrackets:
# Enabled: false
Style/StringLiterals:
Enabled: false

View File

@@ -1,6 +1,6 @@
class AddOnsController < ApplicationController
include StorageHelper
before_action :set_add_on, only: [:show, :edit, :update, :destroy]
before_action :set_add_on, only: [ :show, :edit, :update, :destroy ]
# GET /add_ons
def index

View File

@@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
include Pundit::Authorization
include Pagy::Backend
#protect_from_forgery with: :exception
# protect_from_forgery with: :exception
skip_before_action :verify_authenticity_token
before_action :configure_permitted_parameters, if: :devise_controller?

View File

@@ -1,5 +1,5 @@
class Local::PagesController < ApplicationController
EXPECTED_SCOPES = ["repo", "write:packages"]
EXPECTED_SCOPES = [ "repo", "write:packages" ]
if Rails.application.config.local_mode
skip_before_action :set_github_token_if_not_exists
end

View File

@@ -1,5 +1,5 @@
class Users::RegistrationsController < Devise::RegistrationsController
layout 'homepage', only: [:new, :create]
layout 'homepage', only: [ :new, :create ]
protected
def update_resource(resource, params)

View File

@@ -1,3 +1,3 @@
class Users::SessionsController < Devise::SessionsController
layout 'homepage', only: [:new, :create]
layout 'homepage', only: [ :new, :create ]
end

View File

@@ -13,7 +13,7 @@ module AnnouncementsHelper
{
"new" => "text-success",
"update" => "text-warning",
"fix" => "text-danger",
"fix" => "text-danger"
}.fetch(type, "text-success")
end
end

View File

@@ -3,7 +3,7 @@ module MetricsHelper
metrics.map do |m|
{
created_at: m.created_at,
value: m.metadata[key].to_f,
value: m.metadata[key].to_f
}
end
end

View File

@@ -1,5 +1,4 @@
class Projects::DestroyJob < ApplicationJob
def perform(project)
project.destroying!
kubeconfig = project.cluster.kubeconfig

View File

@@ -28,7 +28,7 @@ class AddOn < ApplicationRecord
include Loggable
belongs_to :cluster
has_one :account, through: :cluster
enum :status, {installing: 0, installed: 1, uninstalling: 2, uninstalled: 3, failed: 4}
enum :status, { installing: 0, installed: 1, uninstalling: 2, uninstalled: 3, failed: 4 }
validates :chart_type, presence: true
validate :chart_type_exists
validates :name, presence: true, format: { with: /\A[a-z0-9_-]+\z/, message: "must be lowercase, numbers, hyphens, and underscores only" }

View File

@@ -19,7 +19,7 @@ class Metric < ApplicationRecord
enum :metric_type, {
cpu: 0,
memory: 1,
storage: 2,
storage: 2
}
scope :node_only_tags, -> {
@@ -27,7 +27,7 @@ class Metric < ApplicationRecord
}
scope :for_project, ->(project) {
where("tags @> ARRAY[?]::jsonb[]", %Q["namespace:#{project.name}"])
where("tags @> ARRAY[?]::jsonb[]", %Q("namespace:#{project.name}"))
}
def tag_value(tag)

View File

@@ -67,5 +67,4 @@ class K8::Helm::Service
output = K8::Kubectl.new(add_on.cluster.kubeconfig, Cli::RunAndReturnOutput.new).call("exec #{service_name} -- df -h /data")
output.strip
end
end

View File

@@ -1,7 +1,7 @@
module K8
module Kubeconfig
def with_kube_config
Tempfile.open(['kubeconfig', '.yaml']) do |kubeconfig_file|
Tempfile.open([ 'kubeconfig', '.yaml' ]) do |kubeconfig_file|
kubeconfig_hash = kubeconfig.is_a?(String) ? JSON.parse(kubeconfig) : kubeconfig
kubeconfig_file.write(kubeconfig_hash.to_yaml)
kubeconfig_file.flush

View File

@@ -2,7 +2,7 @@ class RandomNameGenerator
ADJECTIVES = %w[quick lazy happy brave clever quiet mighty kind shiny eager]
NOUNS = %w[fox bear wolf tiger lion eagle owl deer hare dolphin]
def self.generate_name(prefix=nil)
def self.generate_name(prefix = nil)
adjective = ADJECTIVES.sample
noun = NOUNS.sample
name = "#{adjective}-#{noun}"

View File

@@ -1,6 +1,6 @@
Chartkick.options = {
height: "400px",
colors: ["#4f46e5", "#06b6d4", "#10b981", "#f59e0b", "#ef4444"],
colors: [ "#4f46e5", "#06b6d4", "#10b981", "#f59e0b", "#ef4444" ],
library: {
font: {
family: "'DM Sans', sans-serif"

View File

@@ -32,6 +32,6 @@ class CreateNoticedTables < ActiveRecord::Migration[6.1]
setting = config.options[config.orm][:primary_key_type]
primary_key_type = setting || :primary_key
foreign_key_type = setting || :bigint
[primary_key_type, foreign_key_type]
[ primary_key_type, foreign_key_type ]
end
end

View File

@@ -14,8 +14,8 @@ class CreateFriendlyIdSlugs < MIGRATION_CLASS
t.string :scope
t.datetime :created_at
end
add_index :friendly_id_slugs, [:sluggable_type, :sluggable_id]
add_index :friendly_id_slugs, [:slug, :sluggable_type], length: {slug: 140, sluggable_type: 50}
add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope], length: {slug: 70, sluggable_type: 50, scope: 70}, unique: true
add_index :friendly_id_slugs, [ :sluggable_type, :sluggable_id ]
add_index :friendly_id_slugs, [ :slug, :sluggable_type ], length: { slug: 140, sluggable_type: 50 }
add_index :friendly_id_slugs, [ :slug, :sluggable_type, :scope ], length: { slug: 70, sluggable_type: 50, scope: 70 }, unique: true
end
end

View File

@@ -3,8 +3,8 @@ namespace :metrics do
end
task check_health: :environment do
Service.web_service.where('healthcheck_url IS NOT NULL').each do |service|
#url = File.join("http://#{service.name}-service.#{service.project.name}.svc.cluster.local", service.healthcheck_url)
#K8::Client.from_project(service.project).run_command("curl -s -o /dev/null -w '%{http_code}' #{url}")
# url = File.join("http://#{service.name}-service.#{service.project.name}.svc.cluster.local", service.healthcheck_url)
# K8::Client.from_project(service.project).run_command("curl -s -o /dev/null -w '%{http_code}' #{url}")
if service.domains.any?
url = File.join("https://#{service.domains.first.domain_name}", service.healthcheck_url)
Rails.logger.info("Checking health for #{service.name} at #{url}")