Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit a9a0cff

Browse files
committed
Drop redundant columns from files and folders relations
1 parent 1ab2c44 commit a9a0cff

8 files changed

Lines changed: 11 additions & 464 deletions

File tree

codeql-extractor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ pull_request_triggers:
66
- "**/glide.yaml"
77
- "**/Gopkg.toml"
88
column_kind: "utf8"
9+
extra_env_vars:
10+
CODEQL_REDUCE_FILES_FOLDERS_RELATIONS: "true"
911
file_types:
1012
- name: go
1113
display_name: Go

codeql-tools/pre-finalize.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
@echo off
22
SETLOCAL EnableDelayedExpansion
33

4+
SET CODEQL_REDUCE_FILES_FOLDERS_RELATIONS=true
5+
46
if NOT "%CODEQL_EXTRACTOR_GO_EXTRACT_HTML%"=="no" (
57
type NUL && "%CODEQL_DIST%/codeql.exe" database index-files ^
68
--working-dir=. ^

codeql-tools/pre-finalize.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -eu
44

55
if [ "${CODEQL_EXTRACTOR_GO_EXTRACT_HTML:-yes}" != "no" ]; then
6-
"$CODEQL_DIST/codeql" database index-files \
6+
CODEQL_REDUCE_FILES_FOLDERS_RELATIONS=true "$CODEQL_DIST/codeql" database index-files \
77
--working-dir=. \
88
--include-extension=.htm \
99
--include-extension=.html \

extractor/dbscheme/tables.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -896,16 +896,12 @@ var NumlinesTable = NewTable("numlines",
896896
var FilesTable = NewTable("files",
897897
EntityColumn(FileType, "id").Key(),
898898
StringColumn("name"),
899-
StringColumn("simple"),
900-
StringColumn("ext"),
901-
IntColumn("fromSource"),
902899
)
903900

904901
// FoldersTable is the table defining folder entities
905902
var FoldersTable = NewTable("folders",
906903
EntityColumn(FolderType, "id").Key(),
907904
StringColumn("name"),
908-
StringColumn("simple"),
909905
)
910906

911907
// ContainerParentTable is the table defining the parent-child relation among container entities

extractor/extractor.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -590,15 +590,6 @@ func (extraction *Extraction) extractFile(ast *ast.File, pkg *packages.Package)
590590
return nil
591591
}
592592

593-
// stemAndExt splits a given file name into its stem (the part before the last '.')
594-
// and extension (the part after the last '.')
595-
func stemAndExt(base string) (string, string) {
596-
if i := strings.LastIndexByte(base, '.'); i >= 0 {
597-
return base[:i], base[i+1:]
598-
}
599-
return base, ""
600-
}
601-
602593
// extractFileInfo extracts file-system level information for the given file, populating
603594
// the `files` and `containerparent` tables
604595
func (extraction *Extraction) extractFileInfo(tw *trap.Writer, file string) {
@@ -627,9 +618,8 @@ func (extraction *Extraction) extractFileInfo(tw *trap.Writer, file string) {
627618
path = parentPath + "/" + component
628619
}
629620
if i == len(components)-1 {
630-
stem, ext := stemAndExt(component)
631621
lbl := tw.Labeler.FileLabelFor(file)
632-
dbscheme.FilesTable.Emit(tw, lbl, path, stem, ext, 0)
622+
dbscheme.FilesTable.Emit(tw, lbl, path)
633623
dbscheme.ContainerParentTable.Emit(tw, parentLbl, lbl)
634624
dbscheme.HasLocationTable.Emit(tw, lbl, emitLocation(tw, lbl, 0, 0, 0, 0))
635625
extraction.Lock.Lock()
@@ -639,7 +629,7 @@ func (extraction *Extraction) extractFileInfo(tw *trap.Writer, file string) {
639629
break
640630
}
641631
lbl := tw.Labeler.GlobalID(util.EscapeTrapSpecialChars(path) + ";folder")
642-
dbscheme.FoldersTable.Emit(tw, lbl, path, component)
632+
dbscheme.FoldersTable.Emit(tw, lbl, path)
643633
if i > 0 {
644634
dbscheme.ContainerParentTable.Emit(tw, parentLbl, lbl)
645635
}

ql/src/go.dbscheme

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ locations_default(unique int id: @location_default, int file: @file ref, int beg
133133

134134
numlines(int element_id: @sourceline ref, int num_lines: int ref, int num_code: int ref, int num_comment: int ref);
135135

136-
files(unique int id: @file, string name: string ref, string simple: string ref, string ext: string ref, int fromSource: int ref);
136+
files(unique int id: @file, string name: string ref);
137137

138-
folders(unique int id: @folder, string name: string ref, string simple: string ref);
138+
folders(unique int id: @folder, string name: string ref);
139139

140140
containerparent(int parent: @container ref, unique int child: @container ref);
141141

0 commit comments

Comments
 (0)