Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
taketo1113 committed Dec 12, 2024
1 parent 6f561ef commit 80da512
Show file tree
Hide file tree
Showing 47 changed files with 284 additions and 306 deletions.
8 changes: 4 additions & 4 deletions app/controllers/diagnosis_logs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class DiagnosisLogsController < ApplicationController
before_action :authenticate_user!

before_action :set_diagnosis_log, only: [:show, :edit, :update, :destroy]
before_action :set_diagnosis_log, only: [ :show, :edit, :update, :destroy ]

# GET /diagnosis_logs
# GET /diagnosis_logs.json
Expand Down Expand Up @@ -39,7 +39,7 @@ def create

respond_to do |format|
if @diagnosis_log.save
format.html { redirect_to @diagnosis_log, notice: 'Diagnosis log was successfully created.' }
format.html { redirect_to @diagnosis_log, notice: "Diagnosis log was successfully created." }
format.json { render :show, status: :created, location: @diagnosis_log }
else
format.html { render :new, status: :unprocessable_entity }
Expand All @@ -53,7 +53,7 @@ def create
def update
respond_to do |format|
if @diagnosis_log.update(diagnosis_log_params)
format.html { redirect_to @diagnosis_log, notice: 'Diagnosis log was successfully updated.' }
format.html { redirect_to @diagnosis_log, notice: "Diagnosis log was successfully updated." }
format.json { render :show, status: :ok, location: @diagnosis_log }
else
format.html { render :edit, status: :unprocessable_entity }
Expand All @@ -67,7 +67,7 @@ def update
def destroy
@diagnosis_log.destroy
respond_to do |format|
format.html { redirect_to diagnosis_logs_url, status: :see_other, notice: 'Diagnosis log was successfully destroyed.' }
format.html { redirect_to diagnosis_logs_url, status: :see_other, notice: "Diagnosis log was successfully destroyed." }
format.json { head :no_content }
end
end
Expand Down
24 changes: 12 additions & 12 deletions app/controllers/ignore_error_results_controller.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
class IgnoreErrorResultsController < ApplicationController
before_action :authenticate_user!

before_action :set_ignore_error_result, only: [:show, :edit, :update, :destroy]
before_action :set_ignore_error_result, only: [ :show, :edit, :update, :destroy ]

concerning :BreadcrumbFeature do
included do
before_action only: [:index, :show, :new, :create, :edit, :update] do |controller|
add_breadcrumb I18n.t('views.settings.index.title'), ''
add_breadcrumb I18n.t('views.ignore_error_results.index.title'), ignore_error_results_path
before_action only: [ :index, :show, :new, :create, :edit, :update ] do |controller|
add_breadcrumb I18n.t("views.settings.index.title"), ""
add_breadcrumb I18n.t("views.ignore_error_results.index.title"), ignore_error_results_path
end

before_action only: [:show, :edit, :update] do |controller|
before_action only: [ :show, :edit, :update ] do |controller|
add_breadcrumb "#{@ignore_error_result.ssid}", ignore_error_result_path(@ignore_error_result)
end

before_action only: [:new, :create] do |controller|
add_breadcrumb I18n.t('views.ignore_error_results.new.title'), new_ignore_error_result_path
before_action only: [ :new, :create ] do |controller|
add_breadcrumb I18n.t("views.ignore_error_results.new.title"), new_ignore_error_result_path
end

before_action only: [:edit, :update] do |controller|
add_breadcrumb I18n.t('views.ignore_error_results.edit.title'), edit_ignore_error_result_path(@ignore_error_result)
before_action only: [ :edit, :update ] do |controller|
add_breadcrumb I18n.t("views.ignore_error_results.edit.title"), edit_ignore_error_result_path(@ignore_error_result)
end
end
end
Expand Down Expand Up @@ -51,7 +51,7 @@ def create

respond_to do |format|
if @ignore_error_result.save
format.html { redirect_to @ignore_error_result, notice: 'Ignore error result was successfully created.' }
format.html { redirect_to @ignore_error_result, notice: "Ignore error result was successfully created." }
format.json { render :show, status: :created, location: @ignore_error_result }
else
format.html { render :new, status: :unprocessable_entity }
Expand All @@ -65,7 +65,7 @@ def create
def update
respond_to do |format|
if @ignore_error_result.update(ignore_error_result_params)
format.html { redirect_to @ignore_error_result, notice: 'Ignore error result was successfully updated.' }
format.html { redirect_to @ignore_error_result, notice: "Ignore error result was successfully updated." }
format.json { render :show, status: :ok, location: @ignore_error_result }
else
format.html { render :edit, status: :unprocessable_entity }
Expand All @@ -79,7 +79,7 @@ def update
def destroy
@ignore_error_result.destroy
respond_to do |format|
format.html { redirect_to ignore_error_results_url, status: :see_other, notice: 'Ignore error result was successfully destroyed.' }
format.html { redirect_to ignore_error_results_url, status: :see_other, notice: "Ignore error result was successfully destroyed." }
format.json { head :no_content }
end
end
Expand Down
9 changes: 5 additions & 4 deletions app/controllers/log_campaigns_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# coding: utf-8

class LogCampaignsController < ApplicationController
before_action :authenticate_user!

before_action :set_log_campaign, only: [:show, :all, :log, :error, :edit, :update, :destroy]
before_action :set_log_campaign, only: [ :show, :all, :log, :error, :edit, :update, :destroy ]

# GET /log_campaigns
# GET /log_campaigns.json
Expand Down Expand Up @@ -93,7 +94,7 @@ def create

respond_to do |format|
if @log_campaign.save
format.html { redirect_to @log_campaign, notice: 'Log campaign was successfully created.' }
format.html { redirect_to @log_campaign, notice: "Log campaign was successfully created." }
format.json { render :show, status: :created, location: @log_campaign }
else
format.html { render :new, status: :unprocessable_entity }
Expand All @@ -107,7 +108,7 @@ def create
def update
respond_to do |format|
if @log_campaign.update(log_campaign_params)
format.html { redirect_to @log_campaign, notice: 'Log campaign was successfully updated.' }
format.html { redirect_to @log_campaign, notice: "Log campaign was successfully updated." }
format.json { render :show, status: :ok, location: @log_campaign }
else
format.html { render :edit, status: :unprocessable_entity }
Expand All @@ -121,7 +122,7 @@ def update
def destroy
@log_campaign.destroy
respond_to do |format|
format.html { redirect_to log_campaigns_url, status: :see_other, notice: 'Log campaign was successfully destroyed.' }
format.html { redirect_to log_campaigns_url, status: :see_other, notice: "Log campaign was successfully destroyed." }
format.json { head :no_content }
end
end
Expand Down
12 changes: 6 additions & 6 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module ApplicationHelper
def full_title(page_title = nil)
base_title = t('common.site_title')
base_title = t("common.site_title")

if page_title.blank?
base_title
Expand All @@ -20,18 +20,18 @@ def hbr(str)

def datetime_view(datetime)
return nil if datetime.blank?
datetime.strftime(t('time.formats.default'))
datetime.strftime(t("time.formats.default"))
end

def date_view(date)
return nil if date.blank?
date.strftime(t('date.formats.default'))
date.strftime(t("date.formats.default"))
end

# CSS Class
def current_class(target_path)
if current_page?(target_path)
'active'
"active"
end
end

Expand All @@ -40,10 +40,10 @@ def current_class(target_path)
# parent - The Resource that has_* child
# child - The Resource that belongs_to parent.
def shallow_args(parent, child)
params[:action] == 'new' ? [parent, child] : child
params[:action] == "new" ? [ parent, child ] : child
end

def shallow_deep_args(parent, child, grandchild)
params[:action] == 'new' ? [parent, child, grandchild] : grandchild
params[:action] == "new" ? [ parent, child, grandchild ] : grandchild
end
end
36 changes: 18 additions & 18 deletions app/models/diagnosis_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ class DiagnosisLog < ApplicationRecord
enum :result, {
fail: 0,
success: 1,
information: 10,
information: 10
}

cattr_reader :layer_defs
@@layer_defs = {
hardware: 'ハードウェア層',
datalink: 'データリンク層',
interface: 'インタフェース設定層',
localnet: 'ローカルネットワーク層',
globalnet: 'グローバルネットワーク層',
dns: '名前解決層',
web: 'ウェブアプリケーション層',
app: 'アプリケーション層',
hardware: "ハードウェア層",
datalink: "データリンク層",
interface: "インタフェース設定層",
localnet: "ローカルネットワーク層",
globalnet: "グローバルネットワーク層",
dns: "名前解決層",
web: "ウェブアプリケーション層",
app: "アプリケーション層"
}

cattr_reader :log_type_defs
Expand All @@ -28,7 +28,7 @@ class DiagnosisLog < ApplicationRecord
"v6autoconf", "ra_prefixes", "ra_flags", "v4ifconf", "v6ifconf",
"v4nameservers", "v4routers", "v4autoconf", "v4addr", "netmask",
"v6lladdr", "rate", "channel", "ifstatus", "ssid",
"iftype", "rssi", "bssid", "noise", "ifmtu",
"iftype", "rssi", "bssid", "noise", "ifmtu"
]

default_scope { order(occurred_at: :desc) }
Expand Down Expand Up @@ -57,39 +57,39 @@ def layer_label

def result_label
if self.result.nil?
return ''
return ""
end

ignore_log_types = IgnoreErrorResult.ignore_log_types_by_ssid(self.log_campaign.try(:ssid)) || Array.new

if ignore_log_types.include?(self.log_type)
return 'table-warning'
return "table-warning"
end

if self.fail?
return 'table-danger'
return "table-danger"
end

if self.success?
return "table-success"
end

return ""
""
end

def log
"#{self.layer_label}(#{self.log_group}) #{self.log_type}<br />#{self.detail}"
end

def self.date_list
return []
#Rails.cache.fetch("date_list") do
[]
# Rails.cache.fetch("date_list") do
# DiagnosisLog.occurred_after(DateTime.now - 10.days).pluck(:occurred_at).map{ |occurred_at| occurred_at.to_date.to_s unless occurred_at.blank? }.uniq
#end
# end
end

# for ransacker
ransacker :occurred_at do
Arel.sql('date(occurred_at)')
Arel.sql("date(occurred_at)")
end
end
16 changes: 8 additions & 8 deletions app/models/log_campaign.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,36 @@ def result
ignore_log_types = IgnoreErrorResult.ignore_log_types_by_ssid(self.ssid)

if self.diagnosis_logs.fail.where(log_type: ignore_log_types).count > 0
return 'warning'
return "warning"
end

if self.diagnosis_logs.fail.count > 0
return 'fail'
return "fail"
end

if self.diagnosis_logs.success.count > 0
return 'success'
return "success"
end

return 'information'
"information"
end

def result_label
ignore_log_types = IgnoreErrorResult.ignore_log_types_by_ssid(self.ssid)

if self.diagnosis_logs.fail.where(log_type: ignore_log_types).count > 0
return 'table-warning'
return "table-warning"
end

if self.diagnosis_logs.fail.count > 0
return 'table-danger'
return "table-danger"
end

if self.diagnosis_logs.success.count > 0
return 'table-success'
return "table-success"
end

return ''
""
end

def self.ssid_list
Expand Down
2 changes: 1 addition & 1 deletion app/views/diagnosis_logs/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
json.array!(@diagnosis_logs) do |diagnosis_log|
json.extract! diagnosis_log, :id, :layer, :log_group, :log_type, :log_campaign_uuid: :target, :result, :detail, :occurred_at
json.extract! diagnosis_log, :id, :layer, :log_group, :log_type, :log_campaign_uuid, :target, :result, :detail, :occurred_at
json.url diagnosis_log_url(diagnosis_log, format: :json)
end
2 changes: 1 addition & 1 deletion app/views/ignore_error_results/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1 +1 @@
json.array! @ignore_error_results, partial: 'ignore_error_results/ignore_error_result', as: :ignore_error_result
json.array! @ignore_error_results, partial: "ignore_error_results/ignore_error_result", as: :ignore_error_result
Loading

0 comments on commit 80da512

Please sign in to comment.