Skip to content

Commit

Permalink
work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
rajivramv committed Jun 19, 2019
1 parent d6d23f6 commit 5198c95
Show file tree
Hide file tree
Showing 22 changed files with 401 additions and 80 deletions.
17 changes: 16 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
# Simple Linter
This utility lints source code to verify if it conforms to [Google's Style Guide](https://github.com/google/styleguide). It uses [checkstyle](https://checkstyle.org/index.html) and [cpplint](https://github.com/google/styleguide/tree/gh-pages/cpplint) for the linting. Currently implemented languages: Java, C++.

### Dependencies
1. Node.js >= v10.11.3
2. Python >= v3.5
3. Java & JRE

### Installation
1. Install java and jre from deb package openjdk-9-jre-headless. Use command `sudo apt-get install openjdk-9-jre-headless`
1. Install Node.js >= v10.11.3 using [node version manager](https://github.com/nvm-sh/nvm#install--update-script).
2. Install java and jre from deb package openjdk-9-jre-headless or any other suitable version. Use command `sudo apt-get install openjdk-9-jre-headless`.
3. [Download](https://www.python.org/downloads/) and install Python >= v3.5.
4. Clone the repository and run `npm install` inside `api-service` and `app`.
5. Start the Api service by running `npm run dev` inside `api-service`.
6. Start the App by running `npm start` inside `app`.


4 changes: 2 additions & 2 deletions api-service/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "api-service",
"version": "0.1.0",
"description": "Backend for code analyzer",
"description": "Backend for code linter",
"main": "dist",
"scripts": {
"build": "tsc",
Expand All @@ -11,7 +11,7 @@
},
"keywords": [
"Code",
"analyzer",
"linter",
"backend"
],
"author": "Rajiv Ram V <[email protected]>",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import { spawn } from "child_process";
import { writeFile } from "fs";
import tmp from "tmp";

export interface IAnalyzeRequest {
export interface ILintRequest {
code: string;
lang: string;
}

export interface IAnalyzeResult {
export interface ILintResult {
lang: "cpp" | "java";
errors: string;
completed: string;
}

export const analyze = (job: IAnalyzeRequest): Promise<IAnalyzeResult> => {
export const lint = (job: ILintRequest): Promise<ILintResult> => {
return new Promise((resolve, reject) => {
switch (job.lang) {
case "cpp":
Expand Down Expand Up @@ -73,3 +73,7 @@ export const analyze = (job: IAnalyzeRequest): Promise<IAnalyzeResult> => {
}
});
};

// const detectLanguage = (code: string): Promise<string> => {

// }
8 changes: 4 additions & 4 deletions api-service/src/routes.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Context } from "koa";
import Router from "koa-router";

import { analyze, IAnalyzeRequest } from "./analyzers";
import { ILintRequest, lint } from "./linters";
const router = new Router();

router.get("/test", async (ctx: Context) => {
ctx.body = "Hello World!";
});

router.post("/analyze", async (ctx: Context) => {
const job = ctx.request.body as IAnalyzeRequest;
const result = await analyze(job);
router.post("/lint", async (ctx: Context) => {
const job = ctx.request.body as ILintRequest;
const result = await lint(job);
ctx.body = result;
});

Expand Down
2 changes: 2 additions & 0 deletions app/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PORT=4000
REACT_APP_API_URI=http://localhost:3000
Loading

0 comments on commit 5198c95

Please sign in to comment.