Skip to content

Commit bc2490c

Browse files
committed
Added Library.Lint() function
1 parent 4a40179 commit bc2490c

File tree

2 files changed

+59
-20
lines changed

2 files changed

+59
-20
lines changed

arduino/libraries/lint.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* This file is part of arduino-cli.
3+
*
4+
* arduino-cli is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, write to the Free Software
16+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*
18+
* As a special exception, you may use this file as part of a free software
19+
* library without restriction. Specifically, if other files instantiate
20+
* templates or use macros or inline functions from this file, or you compile
21+
* this file and link it with other files to produce an executable, this
22+
* file does not by itself cause the resulting executable to be covered by
23+
* the GNU General Public License. This exception does not however
24+
* invalidate any other reasons why the executable file might be covered by
25+
* the GNU General Public License.
26+
*
27+
* Copyright 2018 ARDUINO AG (http://www.arduino.cc/)
28+
*/
29+
30+
package libraries
31+
32+
// Lint produce warnings about the formal correctness of a Library
33+
func (l *Library) Lint() ([]string, error) {
34+
35+
// TODO: check for spurious folders
36+
// subFolders, err := ioutil.ReadDir(libraryFolder)
37+
// if err != nil {
38+
// return nil, fmt.Errorf("reading dir %s: %s", libraryFolder, err)
39+
// }
40+
// for _, subFolder := range subFolders {
41+
// if utils.IsSCCSOrHiddenFile(subFolder) {
42+
// if !utils.IsSCCSFile(subFolder) && utils.IsHiddenFile(subFolder) {
43+
// logger.Fprintln(os.Stdout, "warn",
44+
// "WARNING: Spurious {0} folder in '{1}' library",
45+
// filepath.Base(subFolder.Name()), libProperties["name"])
46+
// }
47+
// }
48+
// }
49+
50+
// TODO: check for invalid category in library.properties
51+
// if !ValidCategories[libProperties["category"]] {
52+
// logger.Fprintln(os.Stdout, "warn",
53+
// "WARNING: Category '{0}' in library {1} is not valid. Setting to '{2}'",
54+
// libProperties["category"], libProperties["name"], "Uncategorized")
55+
// libProperties["category"] = "Uncategorized"
56+
// }
57+
58+
return []string{}, nil
59+
}

arduino/libraries/loader.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,6 @@ func makeNewLibrary(libraryFolder string) (*Library, error) {
8080
addUtilityFolder(library)
8181
}
8282

83-
// subFolders, err := ioutil.ReadDir(libraryFolder)
84-
// if err != nil {
85-
// return nil, fmt.Errorf("reading dir %s: %s", libraryFolder, err)
86-
// }
87-
88-
// if debugLevel >= 0 {
89-
// for _, subFolder := range subFolders {
90-
// if utils.IsSCCSOrHiddenFile(subFolder) {
91-
// if !utils.IsSCCSFile(subFolder) && utils.IsHiddenFile(subFolder) {
92-
// logger.Fprintln(os.Stdout, "warn",
93-
// "WARNING: Spurious {0} folder in '{1}' library",
94-
// filepath.Base(subFolder.Name()), libProperties["name"])
95-
// }
96-
// }
97-
// }
98-
// }
99-
10083
if libProperties["architectures"] == "" {
10184
libProperties["architectures"] = "*"
10285
}
@@ -107,9 +90,6 @@ func makeNewLibrary(libraryFolder string) (*Library, error) {
10790

10891
libProperties["category"] = strings.TrimSpace(libProperties["category"])
10992
if !ValidCategories[libProperties["category"]] {
110-
// logger.Fprintln(os.Stdout, "warn",
111-
// "WARNING: Category '{0}' in library {1} is not valid. Setting to '{2}'",
112-
// libProperties["category"], libProperties["name"], "Uncategorized")
11393
libProperties["category"] = "Uncategorized"
11494
}
11595
library.Category = libProperties["category"]

0 commit comments

Comments
 (0)