Skip to content

Commit 7fe824d

Browse files
committed
Fix issues with unused variables
1 parent 3035306 commit 7fe824d

File tree

88 files changed

+551
-434
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+551
-434
lines changed

.luacheckrc

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
-- luacheck: ignore 131
12
include_files = { "src/**/*.lua"}
23
exclude_files = {
34
"mobdebug.lua",
@@ -28,10 +29,7 @@ globals = {
2829
"plugindef"
2930
}
3031
codes = true
31-
unused = false
32-
unused_args = false
3332
ignore = {
3433
"6..", -- formatting
35-
"131", -- Unused implicitly defined global variable
3634
}
37-
allow_defined = true
35+
allow_defined_top = true

src/articulation_autoposition_rolled_chords.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function articulation_autoposition_rolled_chords()
114114
artic.Visible = false
115115
else
116116
local this_bottom = note_entry.get_bottom_note_position(entry)
117-
staff_scale = mm.StaffScaling / 10000
117+
local staff_scale = mm.StaffScaling / 10000
118118
top_page_pos = top_page_pos / staff_scale
119119
bottom_page_pos = bottom_page_pos / staff_scale
120120
left_page_pos = left_page_pos / staff_scale

src/articulation_delete_duplicates.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ function articulation_delete_duplicates()
1717
end
1818
local sort_list = {}
1919
local unique_list = {}
20-
for k,v in ipairs(art_list) do
20+
for _, v in ipairs(art_list) do
2121
if (not sort_list[v]) then
2222
unique_list[#unique_list + 1] = v
2323
sort_list[v] = true
2424
end
2525
end
26-
for key, value in pairs(art_list) do
26+
for _, _ in pairs(art_list) do
2727
for a in each(arts) do
2828
a:DeleteData()
2929
end
3030
end
31-
for key, value in pairs(unique_list) do
31+
for _, value in pairs(unique_list) do
3232
local art = finale.FCArticulation()
3333
art:SetNoteEntry(note_entry)
3434
art:SetID(value) art:SaveNew()

src/baseline_move_reset.lua

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ function baseline_move()
140140
if direction ~= 0 then
141141
baselines:LoadAllForSystem(baseline_type, i)
142142
for j = start_slot, end_slot do
143+
local bl
143144
if valid_lyric_nums then
144145
for lyric_info, _ in pairs(valid_lyric_nums) do
145146
local _, lyric_number = table.unpack(lyric_info)

src/cue_notes_create.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ function new_expression_category(new_name)
600600
local tfi = new_category:CreateTextFontInfo()
601601
tfi.Size = tfi.Size - config.cue_font_smaller
602602
new_category:SetTextFontInfo(tfi)
603-
ok = new_category:SaveNewWithType(finale.DEFAULTCATID_TECHNIQUETEXT)
603+
local ok = new_category:SaveNewWithType(finale.DEFAULTCATID_TECHNIQUETEXT)
604604
if ok then
605605
category_id = new_category:GetID()
606606
end

src/cue_notes_overlay.lua

+2-3
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,9 @@ local function make_info_button(dialog, x, y)
172172
end
173173

174174
local function get_staff_name(staff_num)
175-
local str = finale.FCString()
176175
local staff = finale.FCStaff() -- copy the source Staff Name
177176
staff:Load(staff_num)
178-
str = staff:CreateDisplayFullNameString()
177+
local str = staff:CreateDisplayFullNameString()
179178
local name = { full = str.LuaString }
180179
str = staff:CreateDisplayAbbreviatedNameString()
181180
name.abbrev = str.LuaString
@@ -649,7 +648,7 @@ local function new_expression_category(new_name)
649648
local tfi = new_category:CreateTextFontInfo()
650649
tfi.Size = tfi.Size - config.cue_font_smaller
651650
new_category:SetTextFontInfo(tfi)
652-
ok = new_category:SaveNewWithType(finale.DEFAULTCATID_TECHNIQUETEXT)
651+
local ok = new_category:SaveNewWithType(finale.DEFAULTCATID_TECHNIQUETEXT)
653652
if ok then
654653
category_id = new_category:GetID()
655654
end

src/document_options_as_json.lua

+1-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function do_file_open_dialog(document)
101101
local text_extension = ".json"
102102
local filter_text = "JSON files"
103103

104-
local path_name, file_name = get_path_and_file(document)
104+
local path_name, _ = get_path_and_file(document)
105105
local open_dialog = mixin.FCMFileOpenDialog(finenv.UI())
106106
:SetWindowTitle(fcstr("Open JSON Settings"))
107107
:SetInitFolder(path_name)
@@ -158,7 +158,6 @@ function do_save_as_dialog(document)
158158
local filter_text = "JSON files"
159159

160160
local path_name, file_name = get_path_and_file(document)
161-
local full_file_name = file_name.LuaString
162161
local extension = mixin.FCMString()
163162
:SetLuaString(file_name.LuaString)
164163
:ExtractFileExtension()

src/dynamics_move_above_staff.lua

+65-81
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ end
1212

1313
function dyn_above()
1414
local region = finenv.Region()
15-
local start_msr = region.StartMeasure
16-
local end_msr = region.EndMeasure
17-
local start_staff = region.StartStaff
18-
local end_staff = region.EndStaff
15+
local start_msr = region.StartMeasure
16+
local end_msr = region.EndMeasure
17+
local start_staff = region.StartStaff
18+
local end_staff = region.EndStaff
1919
local measures = finale.FCMeasures()
2020
measures:LoadRegion(region)
2121
local sysstaves = finale.FCSystemStaves()
@@ -29,101 +29,91 @@ function dyn_above()
2929
local baseline = finale.FCBaseline()
3030
baseline.Mode = finale.BASELINEMODE_EXPRESSIONABOVE
3131
baseline:LoadDefaultForMode(finale.BASELINEMODE_EXPRESSIONABOVE)
32-
baseline_off = baseline.VerticalOffset
33-
print("Above Staff Baseline is",baseline_off)
34-
local move_by = -84
32+
local baseline_off = baseline.VerticalOffset
33+
print("Above Staff Baseline is", baseline_off)
3534
local e_vert_target = 0
3635
local h_vert_target = 0
37-
local sys_ref_line = 0
3836
local vocal_dynamic_offset = 36 -- Distance above reference line to place dynamics, in absence of other entries
3937

40-
function metrics(sys_region)
41-
print("metrics function called")
42-
local highest = 0
43-
local hairpins = 0
44-
measures:LoadRegion(sys_region)
45-
for msr in each(measures) do
46-
print("Analyzing measure",msr.ItemNo)
47-
cell = finale.FCCell(msr.ItemNo, sys_region.StartStaff)
38+
local function metrics(sys_region)
39+
print("metrics function called")
40+
local highest = 0
41+
local hairpins
42+
measures:LoadRegion(sys_region)
43+
local cellmetrics, staff_scale
44+
for msr in each(measures) do
45+
print("Analyzing measure", msr.ItemNo)
46+
local cell = finale.FCCell(msr.ItemNo, sys_region.StartStaff)
4847
cellmetrics = cell:CreateCellMetrics()
4948
--**** May need to account for cellmetrics:GetStaffScaling()...
5049
staff_scale = cellmetrics:GetStaffScaling() / 10000
5150
if cellmetrics.ReferenceLinePos + vocal_dynamic_offset > highest then
5251
highest = cellmetrics.ReferenceLinePos + vocal_dynamic_offset
5352
end
54-
end -- for msr..
53+
end -- for msr..
5554
for entry in eachentry(sys_region) do
5655
local e_metrics = finale.FCEntryMetrics()
5756
e_metrics:Load(entry)
58-
local e_highest = e_metrics:GetTopPosition() / staff_scale
59-
if e_highest + vocal_dynamic_offset > highest then
60-
highest = e_highest + vocal_dynamic_offset
61-
end
57+
local e_highest = e_metrics:GetTopPosition() / staff_scale
58+
if e_highest + vocal_dynamic_offset > highest then
59+
highest = e_highest + vocal_dynamic_offset
60+
end
6261
end
63-
hairpins = highest - cellmetrics.ReferenceLinePos +12
62+
hairpins = highest - cellmetrics.ReferenceLinePos +12
6463

65-
return highest, hairpins
66-
end -- function metrics
64+
return highest, hairpins
65+
end -- function metrics
6766

68-
function expr_move(staff_region, e_vert_target) -- luacheck: ignore e_vert_target
69-
local expressions = finale.FCExpressions()
70-
expressions:LoadAllForRegion(staff_region)
71-
for e in each(expressions) do
72-
local dynamic = false
73-
local sed = e:CreateTextExpressionDef()
74-
local cat_ID = sed:GetCategoryID()
75-
local cd = finale.FCCategoryDef()
76-
if cd:Load(cat_ID) then
77-
local cat_name = cd:CreateName()
78-
--print(cat_name.LuaString)
79-
if cat_name.LuaString == "Dynamics" then
80-
dynamic = true
67+
local function expr_move(staff_region, e_vert_target) -- luacheck: ignore e_vert_target
68+
local expressions = finale.FCExpressions()
69+
expressions:LoadAllForRegion(staff_region)
70+
for e in each(expressions) do
71+
local dynamic = false
72+
local sed = e:CreateTextExpressionDef()
73+
local cat_ID = sed:GetCategoryID()
74+
local cd = finale.FCCategoryDef()
75+
if cd:Load(cat_ID) then
76+
local cat_name = cd:CreateName()
77+
--print(cat_name.LuaString)
78+
if cat_name.LuaString == "Dynamics" then
79+
dynamic = true
80+
end
8181
end
82-
end
83-
if dynamic == true then
84-
print("VerticalPos",e.VerticalPos)
85-
local e_metric = finale.FCPoint(0, 0)
86-
cell = finale.FCCell(e.Measure, e.Staff)
87-
cellmetrics = cell:CreateCellMetrics()
88-
---- CHANGE ME!
89-
--e_vert_target = cellmetrics.ReferenceLinePos + baseline_off + move_by - 12 -- vert_target could be calculated somehwere else...
90-
----
91-
print("Vertical Target is",e_vert_target)
92-
e:CalcMetricPos(e_metric)
93-
print("Expression Y is",e_metric.Y)
94-
e:SetVerticalPos(e.VerticalPos + (e_vert_target - e_metric.Y))
95-
e:Save()
96-
end -- if dynamic == true
97-
end -- for e...
98-
end -- func expr_move
82+
if dynamic == true then
83+
print("VerticalPos",e.VerticalPos)
84+
local e_metric = finale.FCPoint(0, 0)
85+
print("Vertical Target is",e_vert_target)
86+
e:CalcMetricPos(e_metric)
87+
print("Expression Y is",e_metric.Y)
88+
e:SetVerticalPos(e.VerticalPos + (e_vert_target - e_metric.Y))
89+
e:Save()
90+
end -- if dynamic == true
91+
end -- for e...
92+
end -- func expr_move
9993

10094

101-
function hairpin_move(staff_region, h_vert_target) -- luacheck: ignore h_vert_target
95+
local function hairpin_move(staff_region, h_vert_target) -- luacheck: ignore h_vert_target
10296
local ssmm = finale.FCSmartShapeMeasureMarks()
10397
ssmm:LoadAllForRegion(staff_region, true)
10498
for mark in each(ssmm) do
10599
local smart_shape = mark:CreateSmartShape()
106100
if smart_shape:IsHairpin() then
107101
print("found hairpin")
108-
local left_seg = smart_shape:GetTerminateSegmentLeft()
109-
local right_seg = smart_shape:GetTerminateSegmentRight()
110-
-- left_seg:SetEndpointOffsetY(baseline_off + move_by)
111-
-- right_seg:SetEndpointOffsetY(baseline_off + move_by)
112-
left_seg:SetEndpointOffsetY(h_vert_target)
113-
right_seg:SetEndpointOffsetY(h_vert_target)
102+
local left_seg = smart_shape:GetTerminateSegmentLeft()
103+
local right_seg = smart_shape:GetTerminateSegmentRight()
104+
left_seg:SetEndpointOffsetY(h_vert_target)
105+
right_seg:SetEndpointOffsetY(h_vert_target)
114106

115-
smart_shape:Save()
116-
107+
smart_shape:Save()
117108
end
118109
end
119-
end -- func hairpin_move
110+
end -- func hairpin_move
120111

121-
function analyze_staves()
122-
for i = start_staffsys.ItemNo, end_staffsys.ItemNo, 1 do
123-
print("Analyzing staffsys",i)
124-
staffsys:Load(i)
125-
local sys_region_start = 0
126-
local sys_region_end = 0
112+
local function analyze_staves()
113+
for i = start_staffsys.ItemNo, end_staffsys.ItemNo, 1 do
114+
print("Analyzing staffsys",i)
115+
staffsys:Load(i)
116+
local sys_region_start, sys_region_end
127117
if start_msr > staffsys.FirstMeasure then
128118
sys_region_start = start_msr
129119
else
@@ -143,19 +133,13 @@ function analyze_staves()
143133
sys_region:SetEndStaff(j)
144134
e_vert_target, h_vert_target = metrics(sys_region)
145135
print("vert_target for staff",j,"is",e_vert_target)
146-
expr_move(sys_region, e_vert_target)
147-
hairpin_move(sys_region, h_vert_target)
136+
expr_move(sys_region, e_vert_target)
137+
hairpin_move(sys_region, h_vert_target)
148138
end -- for j = start_staff...
139+
end -- for i...
140+
end -- function
149141

150-
end -- for i...
151-
end -- function
152-
153-
analyze_staves()
154-
155-
--[[
156-
expr_move()
157-
hairpin_move()
158-
]]
142+
analyze_staves()
159143

160144
end -- function
161145

src/expression_find_orphaned_definitions.lua

+5-5
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ local get_report_string_for_orphans = function(orphaned_exps, is_for_shape)
3131
end
3232
local report_string = ""
3333
local is_first = true
34-
for k, v in pairs(orphaned_exps) do
35-
local exp_def = nil
34+
for _, v in pairs(orphaned_exps) do
35+
local exp_def
3636
if is_for_shape then
3737
exp_def = finale.FCShapeExpressionDef()
3838
else
@@ -60,7 +60,7 @@ local get_report_string_for_orphans = function(orphaned_exps, is_for_shape)
6060
end
6161

6262
local expression_find_orphans_for_type = function(is_for_shape)
63-
local exp_def = nil
63+
local exp_def
6464
if is_for_shape then
6565
exp_def = finale.FCShapeExpressionDef()
6666
else
@@ -85,8 +85,8 @@ local expression_find_orphans_for_type = function(is_for_shape)
8585
end
8686

8787
function expression_find_orphaned_definitions()
88-
local orphaned_text_exps, text_max_valid, text_max_found = expression_find_orphans_for_type(false)
89-
local orphaned_shape_exps, shape_max_valid, shape_max_found = expression_find_orphans_for_type(true)
88+
local orphaned_text_exps, text_max_valid, _ = expression_find_orphans_for_type(false)
89+
local orphaned_shape_exps, shape_max_valid, _ = expression_find_orphans_for_type(true)
9090
local got_orphan = false
9191
local report_string = ""
9292
if #orphaned_text_exps > 0 then

src/finale_lua_menu_organizer.lua

+5-11
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ end
9595
local create_template_if_not_found = false -- change this value to `true` if you want the script to create a template file.
9696

9797
local utils = require("library.utils")
98-
local library = require("library.general_library")
9998

10099
local osutils = require("luaosutils")
101100
local menu = osutils.menu
@@ -190,13 +189,12 @@ end
190189

191190
local parse_layout_file_to_menu -- create local variable for recursive call
192191
parse_layout_file_to_menu = function(file, from_menu, to_menu)
193-
local retval = true
194192
local menus_to_delete = {}
195-
local function function_exit(success) -- all function exits must use this exit function
193+
local function function_exit() -- all function exits must use this exit function
196194
for k, _ in pairs(menus_to_delete) do
197195
menu.delete_submenu(k, finenv.GetFinaleMainWindow())
198196
end
199-
return success
197+
return true
200198
end
201199
local function extract_keyword_value(keyword, line)
202200
local result = utils.trim(line:sub(#keyword + 1))
@@ -207,7 +205,6 @@ parse_layout_file_to_menu = function(file, from_menu, to_menu)
207205
end
208206

209207
to_menu = to_menu or from_menu
210-
local from_menu_text = menu.get_title(from_menu, finenv.GetFinaleMainWindow())
211208
while true do
212209
local line = file:read("*line")
213210
if not line then break end
@@ -234,11 +231,9 @@ parse_layout_file_to_menu = function(file, from_menu, to_menu)
234231
end
235232
if line:find(downsubmenu_indicator, 1, true) == 1 then
236233
local submenu = menu.insert_submenu(line:sub(2), to_menu)
237-
if parse_layout_file_to_menu(file, from_menu, submenu) then
238-
retval = true
239-
end
234+
parse_layout_file_to_menu(file, from_menu, submenu)
240235
elseif line:find(upsubmenu_indicator, 1, true) == 1 then
241-
return function_exit(retval)
236+
return function_exit()
242237
elseif line:find(separator_indicator, 1, true) == 1 then
243238
menu.insert_separator(to_menu)
244239
else
@@ -273,11 +268,10 @@ parse_layout_file_to_menu = function(file, from_menu, to_menu)
273268
end
274269
end
275270
end
276-
retval = true
277271
end
278272
end
279273
end
280-
return function_exit(retval)
274+
return function_exit()
281275
end
282276

283277
local function organize_finale_lua_menus()

0 commit comments

Comments
 (0)