Skip to content

Commit

Permalink
chore: remove unused imports & adds license headers
Browse files Browse the repository at this point in the history
  • Loading branch information
isasmendiagus committed Dec 3, 2024
1 parent 0de844d commit 8754c75
Show file tree
Hide file tree
Showing 14 changed files with 238 additions and 47 deletions.
5 changes: 3 additions & 2 deletions src/main/java/com/scanoss/ScannerPostProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ private List<ScanFileResult> applyReplaceRules(@NotNull List<ScanFileResult> res

/**
* Applies remove rules to scan results, filtering out matches based on certain criteria.
*
* <p>
* First, matches are found based on path and/or purl:
* - Rule must match either both path and purl, just the path, or just the purl
*
* <p>
* Then, for each matched result:
* 1. If none of the matching rules define line ranges -> Remove the result
* 2. If any matching rules define line ranges -> Only remove if the result's lines overlap with any rule's line range
Expand Down Expand Up @@ -185,6 +185,7 @@ private List<ScanFileResult> applyRemoveRules(@NotNull List<ScanFileResult> resu

return resultsList;
}

/**
* Finds and returns a list of matching rules for a scan result.
* A rule matches if:
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/scanoss/cli/ScanCommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ public void run() {

/**
* Load the specified file into a string
*
* @param filename filename to load
* @return loaded string
*/
Expand Down
24 changes: 23 additions & 1 deletion src/main/java/com/scanoss/dto/enums/MatchType.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, SCANOSS
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.scanoss.dto.enums;

public enum MatchType {
file,
snippet,
none;
none
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2023, SCANOSS
* Copyright (c) 2024, SCANOSS
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/scanoss/settings/Bom.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, SCANOSS
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.scanoss.settings;

import lombok.Builder;
Expand Down
30 changes: 26 additions & 4 deletions src/main/java/com/scanoss/settings/RemoveRule.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, SCANOSS
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.scanoss.settings;

import com.google.gson.annotations.SerializedName;
Expand All @@ -9,8 +31,8 @@
@Data
@SuperBuilder
public class RemoveRule extends Rule {
@SerializedName("start_line")
private final Integer startLine;
@SerializedName("end_line")
private final Integer endLine;
@SerializedName("start_line")
private final Integer startLine;
@SerializedName("end_line")
private final Integer endLine;
}
29 changes: 25 additions & 4 deletions src/main/java/com/scanoss/settings/ReplaceRule.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, SCANOSS
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.scanoss.settings;

import com.github.packageurl.PackageURL;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;
Expand All @@ -10,7 +31,7 @@
@Data
@SuperBuilder
public class ReplaceRule extends Rule {
@SerializedName("replace_with")
private String replaceWith;
private String license;
@SerializedName("replace_with")
private String replaceWith;
private String license;
}
24 changes: 23 additions & 1 deletion src/main/java/com/scanoss/settings/Rule.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, SCANOSS
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.scanoss.settings;
import com.github.packageurl.PackageURL;

import lombok.Data;
import lombok.experimental.SuperBuilder;
import lombok.extern.slf4j.Slf4j;
Expand Down
23 changes: 22 additions & 1 deletion src/main/java/com/scanoss/settings/Settings.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, SCANOSS
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.scanoss.settings;

import com.google.gson.Gson;
Expand All @@ -16,7 +38,6 @@ public class Settings {
private Bom bom;



/**
* Creates a Settings object from a JSON string
*
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/com/scanoss/utils/LineRange.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, SCANOSS
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.scanoss.utils;

import lombok.Getter;
Expand Down
30 changes: 27 additions & 3 deletions src/main/java/com/scanoss/utils/LineRangeUtils.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
// SPDX-License-Identifier: MIT
/*
* Copyright (c) 2024, SCANOSS
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.scanoss.utils;


Expand All @@ -11,6 +33,7 @@
public class LineRangeUtils {
/**
* Parses a line range string into a list of intervals
*
* @param lineRanges String in format "1-5,7-10"
* @return List of LineInterval objects
*/
Expand Down Expand Up @@ -41,6 +64,7 @@ public static List<LineRange> parseLineRanges(String lineRanges) {

/**
* Checks if two sets of line ranges overlap
*
* @param ranges1 First set of line ranges
* @param ranges2 Second set of line ranges
* @return true if any intervals overlap
Expand All @@ -58,9 +82,9 @@ public static boolean hasOverlappingRanges(List<LineRange> ranges1, List<LineRan

public static boolean hasOverlappingRanges(List<LineRange> ranges, LineRange range) {
for (LineRange interval1 : ranges) {
if (interval1.overlaps(range)) {
return true;
}
if (interval1.overlaps(range)) {
return true;
}
}
return false;
}
Expand Down
Loading

0 comments on commit 8754c75

Please sign in to comment.