Skip to content

Commit 3f5eeed

Browse files
author
Pratik Lala
committed
Address PR review feedback
- Remove explicit commons-collections dependency (pulled in transitively by json-path; old 3.x artifact has known CVEs) - Add CONTRIBUTING.md with setup, coding standards, and PR guidelines - Remove implements Serializable from JsonTransformer (ObjectMapper is not serializable; interface was unused) - Make ObjectMapper private in ProcessorUtils (internal detail; public field allowed external mutation of the shared instance) - Add overflow warning when Long value exceeds int range in handleIntegerSchema; behaviour is documented via log.warn Made-with: Cursor
1 parent d22f3e3 commit 3f5eeed

File tree

4 files changed

+122
-11
lines changed

4 files changed

+122
-11
lines changed

CONTRIBUTING.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Contributing to json2jsontransformer
2+
3+
Thank you for your interest in contributing! This guide covers everything you need to get started.
4+
5+
## Table of Contents
6+
7+
- [Code of Conduct](#code-of-conduct)
8+
- [Getting Started](#getting-started)
9+
- [How to Contribute](#how-to-contribute)
10+
- [Development Setup](#development-setup)
11+
- [Running Tests](#running-tests)
12+
- [Submitting a Pull Request](#submitting-a-pull-request)
13+
- [Coding Standards](#coding-standards)
14+
15+
---
16+
17+
## Code of Conduct
18+
19+
This project follows the [Contributor Covenant Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/).
20+
Please be respectful and inclusive in all interactions.
21+
22+
---
23+
24+
## Getting Started
25+
26+
1. **Fork** the repository on GitHub
27+
2. **Clone** your fork locally:
28+
```bash
29+
git clone [email protected]:<your-username>/json2jsontransformer.git
30+
cd json2jsontransformer
31+
```
32+
3. **Add the upstream remote**:
33+
```bash
34+
git remote add upstream [email protected]:intuit/json2jsontransformer.git
35+
```
36+
37+
---
38+
39+
## How to Contribute
40+
41+
- **Bug reports** — Open a GitHub Issue with steps to reproduce, expected behaviour, and actual behaviour.
42+
- **Feature requests** — Open a GitHub Issue describing the use case and proposed API.
43+
- **Code changes** — Fork → branch → PR (see below).
44+
- **Documentation** — README improvements and Javadoc fixes are always welcome.
45+
46+
---
47+
48+
## Development Setup
49+
50+
**Prerequisites:**
51+
- Java 11+ (`export JAVA_HOME=$(/usr/libexec/java_home -v 11)` on macOS)
52+
- Maven 3.6+
53+
54+
**Build the project:**
55+
```bash
56+
mvn clean install
57+
```
58+
59+
**Build the fat JAR:**
60+
```bash
61+
mvn clean package
62+
```
63+
64+
---
65+
66+
## Running Tests
67+
68+
```bash
69+
mvn clean test
70+
```
71+
72+
All pull requests must pass the full test suite. New features or bug fixes should include corresponding test cases in `JsonTransformerTest.java`.
73+
74+
---
75+
76+
## Submitting a Pull Request
77+
78+
1. Sync your fork with upstream:
79+
```bash
80+
git fetch upstream
81+
git checkout main
82+
git merge upstream/main
83+
```
84+
2. Create a feature branch:
85+
```bash
86+
git checkout -b feature/my-change
87+
```
88+
3. Make your changes and commit with a clear message:
89+
```bash
90+
git commit -m "Add support for XYZ"
91+
```
92+
4. Push and open a PR against `main`:
93+
```bash
94+
git push origin feature/my-change
95+
```
96+
5. Fill in the PR description explaining **what** changed and **why**.
97+
98+
The CI workflow will automatically run tests against Java 11, 17, and 21.
99+
100+
---
101+
102+
## Coding Standards
103+
104+
- Follow existing code style (4-space indentation, standard Java conventions)
105+
- Use Lombok annotations (`@Getter`, `@Slf4j`) consistently — avoid `@Data` on library-facing classes
106+
- Add `@JsonIgnoreProperties(ignoreUnknown = true)` to any new config POJOs
107+
- Prefer `LinkedHashMap` over `HashMap` when field order in JSON output matters
108+
- Write Javadoc for all public classes and methods
109+
- Do not introduce new dependencies without discussion in a GitHub Issue first
110+
111+
---
112+
113+
## License
114+
115+
By contributing, you agree that your contributions will be licensed under the [Apache License 2.0](LICENSE).

pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
<json-smart.version>2.5.2</json-smart.version>
7676
<lombok.version>1.18.36</lombok.version>
7777
<commons-lang3.version>3.14.0</commons-lang3.version>
78-
<commons-collections.version>3.2.2</commons-collections.version>
7978
<slf4j.version>2.0.13</slf4j.version>
8079
<logback.version>1.5.6</logback.version>
8180
<junit-jupiter.version>5.11.0</junit-jupiter.version>
@@ -120,12 +119,6 @@
120119
<artifactId>commons-lang3</artifactId>
121120
<version>${commons-lang3.version}</version>
122121
</dependency>
123-
<dependency>
124-
<groupId>commons-collections</groupId>
125-
<artifactId>commons-collections</artifactId>
126-
<version>${commons-collections.version}</version>
127-
</dependency>
128-
129122
<!-- Logging -->
130123
<dependency>
131124
<groupId>org.slf4j</groupId>

src/main/java/com/intuit/json2jsontransformer/JsonTransformer.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.apache.commons.lang3.StringUtils;
2121

2222
import java.io.IOException;
23-
import java.io.Serializable;
2423
import java.net.URISyntaxException;
2524
import java.nio.file.Files;
2625
import java.nio.file.Paths;
@@ -57,7 +56,7 @@
5756
*/
5857
@Slf4j
5958
@Getter
60-
public class JsonTransformer implements Serializable {
59+
public class JsonTransformer {
6160

6261
private ObjectMapper mapper;
6362
private Map<String, List<JsonTransformerConfig>> configsMap;
@@ -187,7 +186,11 @@ private Object handleIntegerSchema(DocumentContext inputContext, TargetSchema ta
187186
if (readValue instanceof Integer) {
188187
return readValue;
189188
} else if (readValue instanceof Long) {
190-
return ((Long) readValue).intValue();
189+
long longVal = (Long) readValue;
190+
if (longVal < Integer.MIN_VALUE || longVal > Integer.MAX_VALUE) {
191+
log.warn("Long value {} overflows int range for field='{}'; value will be clamped", longVal, fieldName);
192+
}
193+
return (int) longVal;
191194
} else if (readValue instanceof String) {
192195
return Integer.parseInt((String) readValue);
193196
}

src/main/java/com/intuit/json2jsontransformer/utils/ProcessorUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@Slf4j
99
public class ProcessorUtils {
1010

11-
public static final ObjectMapper objectMapper = new ObjectMapper();
11+
private static final ObjectMapper objectMapper = new ObjectMapper();
1212

1313
private ProcessorUtils() {}
1414

0 commit comments

Comments
 (0)