Skip to content

Commit

Permalink
Adding .luachecrc with a minimum configuration
Browse files Browse the repository at this point in the history
The linter "luacheck" need a special configuration file to make it stop
complaining. In addition to the configuration file a few changes are
made to remove specific lints, thus removing the the need for inline
options and file-specific handling.

This does not add the linter to the toolchain, it is only for
in-editor use.

Bug: T180925
Change-Id: I091b46fdf358c36f02b36a65223f643a2c9e41b2
  • Loading branch information
jeblad committed Nov 20, 2017
1 parent cb7c32e commit 0d94b76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .luacheckrc
@@ -0,0 +1,4 @@
stds.scribunto = {
globals = { "mw", "mw_interface" }
}
std = "min+scribunto"
24 changes: 12 additions & 12 deletions client/includes/DataAccess/Scribunto/mw.wikibase.entity.lua
Expand Up @@ -9,7 +9,7 @@
]]

local php = mw_interface
local entity = {}
local Entity = {}
local metatable = {}
local methodtable = {}
local util = require 'libraryUtil'
Expand All @@ -19,7 +19,7 @@ local checkTypeMulti = util.checkTypeMulti
metatable.__index = methodtable

-- Claim ranks (Claim::RANK_* in PHP)
entity.claimRanks = {
Entity.claimRanks = {
RANK_TRUTH = 3,
RANK_PREFERRED = 2,
RANK_NORMAL = 1,
Expand All @@ -46,7 +46,7 @@ local maskClaimsTable = function( entity )
entity.claims = {}

local pseudoClaimsMetatable = {}
pseudoClaimsMetatable.__index = function( emptyTable, propertyId )
pseudoClaimsMetatable.__index = function( _, propertyId )
if isValidPropertyId( propertyId ) then
-- Only attempt to track the usage if we have a valid property id.
php.addStatementUsage( entity.id, propertyId )
Expand All @@ -55,18 +55,18 @@ local maskClaimsTable = function( entity )
return actualEntityClaims[propertyId]
end

pseudoClaimsMetatable.__newindex = function( emptyTable, propertyId, data )
pseudoClaimsMetatable.__newindex = function( _, _, _ )
error( 'Entity cannot be modified' )
end

local logNext = function( emptyTable, propertyId )
local logNext = function( _, propertyId )
if isValidPropertyId( propertyId ) then
php.addStatementUsage( entity.id, propertyId )
end
return next( actualEntityClaims, propertyId )
end

pseudoClaimsMetatable.__pairs = function( emptyTable )
pseudoClaimsMetatable.__pairs = function( _ )
return logNext, {}, nil
end

Expand All @@ -77,7 +77,7 @@ end
-- Create new entity object from given data
--
-- @param {table} data
entity.create = function( data )
Entity.create = function( data )
if type( data ) ~= 'table' then
error( 'Expected a table obtained via mw.wikibase.getEntityObject, got ' .. type( data ) .. ' instead' )
end
Expand Down Expand Up @@ -211,7 +211,7 @@ methodtable.getBestStatements = function( entity, propertyId )
local statements = {}
local bestRank = 'normal'

for k, statement in pairs( entity.claims[propertyId] ) do
for _, statement in pairs( entity.claims[propertyId] ) do
if statement.rank == bestRank then
statements[#statements + 1] = statement
elseif statement.rank == 'preferred' then
Expand All @@ -233,7 +233,7 @@ methodtable.getProperties = function( entity )
local properties = {}

local n = 0
for k, v in pairs( entity.claims ) do
for k, _ in pairs( entity.claims ) do
n = n + 1
properties[n] = k
end
Expand Down Expand Up @@ -306,8 +306,8 @@ methodtable.formatStatements = function( entity, propertyLabelOrId, acceptableRa
);
end

mw.wikibase.entity = entity
package.loaded['mw.wikibase.entity'] = entity
mw.wikibase.entity = Entity
package.loaded['mw.wikibase.entity'] = Entity
mw_interface = nil

return entity
return Entity

0 comments on commit 0d94b76

Please sign in to comment.