Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add analyzers #48

Merged
merged 1 commit into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions analyzer-shellcheck/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins {
id 'java-library'
}

group = 'io.codety'
version = 'unspecified'

dependencies {
implementation project(':scanner-common')

}

test {
useJUnitPlatform()
}

jar {
enabled = true
archiveClassifier = '' //use empty string
version = null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.codety.scanner;

import io.codety.scanner.util.CodetyConstant;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan(CodetyConstant.BASE_PACKAGE) //fixing the NoSuchBeanDefinitionException
//@Profile("!dev")
public class CodetyScannerTestMain implements CommandLineRunner {

@Override
public void run(String... args) throws Exception {

}
}
21 changes: 21 additions & 0 deletions analyzer-stylelint/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
plugins {
id 'java-library'
}

group = 'io.codety'
version = 'unspecified'

dependencies {
implementation project(':scanner-common')

}

test {
useJUnitPlatform()
}

jar {
enabled = true
archiveClassifier = '' //use empty string
version = null
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.codety.scanner;

import io.codety.scanner.util.CodetyConstant;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan(CodetyConstant.BASE_PACKAGE) //fixing the NoSuchBeanDefinitionException
//@Profile("!dev")
public class CodetyScannerTestMain implements CommandLineRunner {

@Override
public void run(String... args) throws Exception {

}
}
29 changes: 29 additions & 0 deletions analyzer-stylelint/src/test/resources/test-output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[
{
"source": "/Users/user/git/codety-scanner/code-issue-examples/css/bad-css.css",
"deprecations": [],
"invalidOptionWarnings": [],
"parseErrors": [],
"errored": true,
"warnings": [
{
"line": 1,
"column": 6,
"endLine": 2,
"endColumn": 2,
"rule": "block-no-empty",
"severity": "error",
"text": "Unexpected empty block (block-no-empty)"
},
{
"line": 4,
"column": 1,
"endLine": 4,
"endColumn": 5,
"rule": "comment-no-empty",
"severity": "error",
"text": "Unexpected empty comment (comment-no-empty)"
}
]
}
]
4 changes: 4 additions & 0 deletions code-issue-examples/css/bad-css.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
hello{
}

/**/
5 changes: 3 additions & 2 deletions image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ FROM amazoncorretto:17-alpine-jdk


RUN apk add --no-cache python3 py3-pip go
RUN apk add --no-cache shellcheck
RUN apk add --no-cache bash openssl ca-certificates git libc6-compat libstdc++ curl cppcheck nodejs npm py3-pylint

RUN npm install --prefix /usr/local/eslint9/ eslint@9.x eslint-plugin-jsdoc eslint-plugin-react eslint-plugin-vue @html-eslint/parser @html-eslint/eslint-plugin
RUN npm install --prefix /usr/local/eslint8/ eslint@8.x typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin

RUN npm install --prefix /usr/local/stylelint/ stylelint
# !!!!!!checkov build will be failed in arm64 environment, you need to append `--platform=linux/amd64` during docker build or run if you use ARM64 environment(e.g. M1+ chips MacBook)
RUN pip3 install checkov --break-system-packages

Expand All @@ -18,10 +19,10 @@ RUN pip3 install checkov --break-system-packages
RUN wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.60.3
RUN golangci-lint --version


RUN apk add --no-cache ruby-dev cmake clang build-base
#RUN export CC=clang
#RUN export CXX=clang++
# the rubocop build is kinda slow in Alpine
RUN gem install -V rubocop
RUN rubocop --version

Expand Down
8 changes: 5 additions & 3 deletions image/publish_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@ fi

echo " ========= Build application end ========":

git tag -a "$DOCKER_BUILD_VERSION" -m "tag version $DOCKER_BUILD_VERSION"
git push origin "$DOCKER_BUILD_VERSION"

#--platform=linux/amd64,linux/arm64
echo " ========= Build and publish images start ========":
docker buildx build --platform=linux/amd64 -t "$DOCKER_IMG":$DOCKER_BUILD_VERSION -t "$DOCKER_IMG":latest -f image/Dockerfile . --push
if [ $? -ne 0 ]; then
echo "Failed to build multi-platform container, create a new builder may fix the issue: '$> docker buildx create --name mybuilder --use ' "
exit 1;
fi


git tag -a "$DOCKER_BUILD_VERSION" -m "tag version $DOCKER_BUILD_VERSION"
git push origin "$DOCKER_BUILD_VERSION"

echo " ========= Build and publish images end ========":

echo "====User below command to test the container: ====="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public enum CodeAnalyzerType {
, golangcilint(20)
, scalastyle(30)
, rubocop(40)
, stylelint(50)
;
public final int codeAnalyzerType;

Expand Down
2 changes: 2 additions & 0 deletions scanner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ dependencies {
implementation project(':analyzer-golangcilint')
implementation project(':analyzer-codety')
implementation project(':analyzer-scalastyle')
implementation project(':analyzer-stylelint')
implementation project(':analyzer-shellcheck')
implementation project(':analyzer-rubocop')


Expand Down
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ include 'analyzer-pylint'
include 'analyzer-trivy'
include 'analyzer-golangcilint'
include 'analyzer-scalastyle'
include 'analyzer-stylelint'
include 'analyzer-shellcheck'
include 'analyzer-rubocop'