<commit_before>import json
import os
import tempfile

from lint.linter import Linter
from lint.util import communicate, find

class Java(Linter):
    language = 'java'
    cmd = ('eclim', '-command', 'java_src_update')

    def communicate(self, cmd, code):
        project = find(os.path.dirname(self.filename), '.project', True)
        if not project:
            return

        filename = self.filename.replace(project, '', 1).lstrip(os.sep)
        project = os.path.basename(project)

        # can't stdin or temp use file - hack time?
        # this *could* become a tmp directory
        # but I'd need to know all files to copy
        # from the source project
        tmp = tempfile.mktemp()
        os.rename(self.filename, tmp)
        # at least we get some inode protection on posix
        inode = None

        with open(self.filename, 'wb') as f:
            f.write(code)
            if os.name == 'posix':
                inode = os.stat(self.filename).st_ino

        try:
            cmd = cmd + ('-p', project, '-f', filename, '-v')
            output = communicate(cmd, '')
        finally:<commit_msg>allow eclim plugin to be enabled by setting<commit_after>import json
import os
import tempfile

from lint.linter import Linter
from lint.util import communicate, find

class Java(Linter):
    language = 'java'
    cmd = ('eclim', '-command', 'java_src_update')
    regex = r'.'

    def communicate(self, cmd, code):
        project = find(os.path.dirname(self.filename), '.project', True)
        if not project:
            return

        filename = self.filename.replace(project, '', 1).lstrip(os.sep)
        project = os.path.basename(project)

        # can't stdin or temp use file - hack time?
        # this *could* become a tmp directory
        # but I'd need to know all files to copy
        # from the source project
        tmp = tempfile.mktemp()
        os.rename(self.filename, tmp)
        # at least we get some inode protection on posix
        inode = None

        with open(self.filename, 'wb') as f:
            f.write(code)
            if os.name == 'posix':
                inode = os.stat(self.filename).st_ino

        try:
            cmd = cmd + ('-p', project, '-f', filename, '-v')
            output = communicate(cmd, '')
        finally:
{'fraction_non_alphanumeric': 0.11376465479808945, 'fraction_numerical': 0.0008684324793747286, 'mean_word_length': 2.096774193548387, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6494582', 'n_tokens_mistral': 677, 'n_tokens_neox': 657, 'n_words': 216}