1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 from mozlint
import result
9 from mozlint
.pathutils
import expand_exclusions
12 def lint(paths
, config
, fix
=None, **lintargs
):
16 if platform
.system() == "Windows":
17 # Windows doesn't have permissions in files
19 return {"results": results
, "fixed": fixed
}
21 files
= list(expand_exclusions(paths
, config
, lintargs
["root"]))
23 if os
.access(f
, os
.X_OK
):
24 if config
.get("allow-shebang"):
25 with
open(f
, "r+") as content
:
26 # Some source files have +x permissions
27 line
= content
.readline()
28 if line
.startswith("#!"):
29 # Check if the file doesn't start with a shebang
30 # if it does, not a warning
34 # We want to fix it, do it and leave
41 "message": "Execution permissions on a source file",
44 results
.append(result
.from_config(config
, **res
))
45 return {"results": results
, "fixed": fixed
}