@dxworks/insider 2.9.1 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,7 @@ jobs:
14
14
  uses: actions/setup-java@v3
15
15
  with:
16
16
  java-version: 11
17
+ distribution: 'adopt'
17
18
 
18
19
  - name: Gradle Build
19
20
  run: gradle clean build
package/config/.ignore CHANGED
@@ -2,3 +2,15 @@
2
2
  **/.git/**
3
3
  **/*.iml
4
4
  **/node_modules/**
5
+ **/*.pdb
6
+ **/*.dll
7
+ **/*.nupkg
8
+ **/.vs/**
9
+ **/bin/Debug/**
10
+ **/bin/Release/**
11
+ **/bin/x64/Debug**
12
+ **/bin/x64/Release/**
13
+ **/obj/Debug/**
14
+ **/obj/Release/**
15
+ **/obj/x64/Debug/**
16
+ **/obj/x64/Release/**
@@ -2,3 +2,15 @@
2
2
  **/.git/**
3
3
  **/*.iml
4
4
  **/node_modules/**
5
+ **/*.pdb
6
+ **/*.dll
7
+ **/*.nupkg
8
+ **/.vs/**
9
+ **/bin/Debug/**
10
+ **/bin/Release/**
11
+ **/bin/x64/Debug**
12
+ **/bin/x64/Release/**
13
+ **/obj/Debug/**
14
+ **/obj/Release/**
15
+ **/obj/x64/Debug/**
16
+ **/obj/x64/Release/**
package/dist/insider.jar CHANGED
Binary file
@@ -2,3 +2,15 @@
2
2
  **/.git/**
3
3
  **/*.iml
4
4
  **/node_modules/**
5
+ **/*.pdb
6
+ **/*.dll
7
+ **/*.nupkg
8
+ **/.vs/**
9
+ **/bin/Debug/**
10
+ **/bin/Release/**
11
+ **/bin/x64/Debug**
12
+ **/bin/x64/Release/**
13
+ **/obj/Debug/**
14
+ **/obj/Release/**
15
+ **/obj/x64/Debug/**
16
+ **/obj/x64/Release/**
Binary file
package/instrument.yml CHANGED
@@ -24,6 +24,10 @@ commands:
24
24
  # win: insider.bat indent
25
25
  # unix: ./insider.sh indent
26
26
 
27
+ - name: insider-cloc
28
+ win: java -Xmx${max-heap} -jar insider.jar count
29
+ unix: java -Xmx${max-heap} -jar insider.jar count
30
+
27
31
  parameters:
28
32
  findConfig: 'config/fingerprints/code_smells.json config/fingerprints/libraries.json config/fingerprints/generated_code.json'
29
33
  inspectConfig: 'config/rules'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxworks/insider",
3
- "version": "2.9.1",
3
+ "version": "2.12.0",
4
4
  "description": "Insider is a belt of tools built on the idea of searching regular expressions in code",
5
5
  "keywords": [
6
6
  "insider",
@@ -0,0 +1 @@
1
+ * Updated ignore list with generated/built artefacts in .NET solutions.
@@ -144,6 +144,8 @@ public class Insider {
144
144
  return new IndentationCount();
145
145
  case InsiderCommand.MEASURE:
146
146
  return new MeasureCommand();
147
+ case InsiderCommand.COUNT:
148
+ return new ClocCommand();
147
149
  default:
148
150
  return null;
149
151
  }
@@ -0,0 +1,91 @@
1
+ package org.dxworks.insider.commands;
2
+
3
+ import org.dxworks.ignorerLibrary.Ignorer;
4
+ import org.dxworks.ignorerLibrary.IgnorerBuilder;
5
+ import org.dxworks.insider.InsiderFile;
6
+ import org.dxworks.insider.configuration.InsiderConfiguration;
7
+
8
+ import java.io.BufferedInputStream;
9
+ import java.io.BufferedWriter;
10
+ import java.io.IOException;
11
+ import java.io.InputStream;
12
+ import java.nio.charset.StandardCharsets;
13
+ import java.nio.file.*;
14
+ import java.nio.file.attribute.BasicFileAttributes;
15
+ import java.util.List;
16
+
17
+ import static org.dxworks.insider.constants.InsiderConstants.CONFIGURATION_FOLDER;
18
+ import static org.dxworks.insider.constants.InsiderConstants.RESULTS_FOLDER;
19
+
20
+ public class ClocCommand implements NoFilesCommand {
21
+ private static final int BUFFER_SIZE = 8192;
22
+
23
+ @Override
24
+ public boolean parse(List<String> args) {
25
+ return args.size() == 1;
26
+ }
27
+
28
+ @Override
29
+ public void execute(List<InsiderFile> insiderFiles, List<String> args) {
30
+ processFolder(InsiderConfiguration.getInstance().getRootFolder());
31
+ }
32
+
33
+ @Override
34
+ public String usage() {
35
+ return "insider count";
36
+ }
37
+
38
+ @Override
39
+ public String getName() {
40
+ return COUNT;
41
+ }
42
+
43
+
44
+ public void processFolder(String folderPath) {
45
+ Path startPath = Paths.get(folderPath);
46
+ Path csvPath = Paths.get(RESULTS_FOLDER, InsiderConfiguration.getInstance().getProjectID() + "-cloc.csv");
47
+
48
+ Ignorer ignorer = new IgnorerBuilder(Paths.get(CONFIGURATION_FOLDER, ".ignore")).compile();
49
+
50
+ try (BufferedWriter writer = Files.newBufferedWriter(csvPath, StandardCharsets.UTF_8)) {
51
+ writer.write("file,lines,size\n");
52
+ Files.walkFileTree(startPath, new SimpleFileVisitor<>() {
53
+ @Override
54
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
55
+ if (ignorer.accepts(file)) {
56
+ long lines = countLines(file);
57
+ long size = Files.size(file);
58
+ String relativePath = startPath.relativize(file).toString();
59
+
60
+ writer.write("\"" + relativePath + "\"" + "," + lines + "," + size);
61
+ writer.newLine();
62
+ }
63
+ return FileVisitResult.CONTINUE;
64
+ }
65
+ });
66
+ } catch (IOException e) {
67
+ e.printStackTrace();
68
+ }
69
+ }
70
+
71
+ private long countLines(Path path) throws IOException {
72
+ long lines = 0;
73
+ try (InputStream in = Files.newInputStream(path);
74
+ BufferedInputStream bis = new BufferedInputStream(in)) {
75
+ byte[] buffer = new byte[BUFFER_SIZE];
76
+ int n;
77
+ while ((n = bis.read(buffer)) != -1) {
78
+ for (int i = 0; i < n; i++) {
79
+ if (buffer[i] == '\n' || buffer[i] == '\r') {
80
+ lines++;
81
+ // Handle CRLF endings
82
+ if (i < n - 1 && buffer[i] == '\r' && buffer[i + 1] == '\n') {
83
+ i++;
84
+ }
85
+ }
86
+ }
87
+ }
88
+ }
89
+ return lines + 1;
90
+ }
91
+ }
@@ -34,7 +34,8 @@ public class HelpCommand implements NoFilesCommand {
34
34
  new InspectCommand(),
35
35
  new ExtractCommand(),
36
36
  new MeasureCommand(),
37
- new IndentationCount())
37
+ new IndentationCount(),
38
+ new ClocCommand())
38
39
  .map(InsiderCommand::usage)
39
40
  .map(s -> "\t" + s)
40
41
  .collect(Collectors.joining("\n"));
@@ -23,6 +23,7 @@ public interface InsiderCommand {
23
23
  String EXTRACT = "extract";
24
24
  String INDENT = "indent";
25
25
  String MEASURE = "measure";
26
+ String COUNT = "count";
26
27
  List<String> VERSION = Arrays.asList("version", "-version", "--version", "-v");
27
28
  List<String> HELP = Arrays.asList("help", "-help", "--help", "-h");
28
29
 
@@ -1 +1 @@
1
- 2.9.1
1
+ 2.12.0